/**
 * @file:          DefaultParam.c
 * @brief:
 * @details:
 * @author:        wjh
 * @date created:  2023.06.08
 * @version:       1.0.0
 * @par copyright (c):
 *
 * @par history (desc):
 *   version:1.0.0, wjh, 2023.06.08,14:51:57
 */
/* Include Files **************************************************************/
#include "DefaultParam.h"
#include "DriverList.h"
#include "ModuleList.h"
#include "string.h"
#include "StepperMotorController.h"
#include "common.h"

/** Version No. rule **
 * FIRMWARE_VERSION_MAJOR: Incompatible API Change, new feature, software reconstruction
 * FIRMWARE_VERSION_MINOR: Compatible API Change, new feature
 * FIRMWARE_VERSION_PATCH: Bug fixes
 * FIRMWARE_VERSION_COMPILED: Minor change
 */
#define FIRMWARE_VERSION_MAJOR ((uint8_t)1)
#define FIRMWARE_VERSION_MINOR ((uint8_t)9)
#define FIRMWARE_VERSION_PATCH ((uint8_t)6)
#define FIRMWARE_VERSION_COMPILED ((uint8_t)4)
#define FIRMWARE_RELEASE_DATE ("2024-06-04 09:57:43")

static const char firmwareVerInfos[32] __attribute__((section(".saverom"))) __attribute__((used)) = "mot0_002_005";

/* Function Define ************************************************************/
void PeriodCorrect(StepperMotorController *self)
{
    /* ****************** */
    /* period settings */
    if (self->param_task_period_s > self->param_pwm_period_s)
    {
        self->n_multiple_of_timmer_tick = (uint16)(self->param_task_period_s / (self->param_pwm_period_s));
    }
    else
    {
        self->n_multiple_of_timmer_tick = 1;
    }
    self->param_task_period_s = self->n_multiple_of_timmer_tick * (self->param_pwm_period_s);
    // self->param_pos_control_period_s = self->param_task_period_s;

    self->param_pos_control_period_s = self->param_pwm_period_s;
    self->param_cur_control_period_s = self->param_pwm_period_s;

    self->controller->param_pos_period = self->param_pos_control_period_s;
    self->controller->param_cur_period = self->param_cur_control_period_s;

    /* ****************** */
    /* period settings */
    // if (self->param_pos_control_period_s > self->param_pwm_period_s)
    // {
    //     self->n_multiple_of_timmer_tick = (uint16)(self->param_pos_control_period_s / (self->param_pwm_period_s));
    // }
    // else
    // {
    //     self->n_multiple_of_timmer_tick = 1;
    // }
    // self->param_task_period_s = self->n_multiple_of_timmer_tick * (self->param_pwm_period_s);
    // self->param_pos_control_period_s = self->param_task_period_s;

    // self->controller->param_pos_period = self->param_pos_control_period_s;
    // self->controller->param_cur_period = self->param_cur_control_period_s;

    /* period settings */
    // if (self->controller->param_pos_control_period_s > self->mcu->param_pwm_period_s)
    // {
    //     self->n_multiple_of_timmer_tick = (uint16)(self->controller->param_pos_control_period_s / (self->mcu->param_pwm_period_s));
    // }
    // else
    // {
    //     self->n_multiple_of_timmer_tick = 1;
    // }
    // self->mcu->param_task_period_s = self->n_multiple_of_timmer_tick * (self->mcu->param_pwm_period_s);
    // self->controller->param_pos_control_period_s = self->mcu->param_task_period_s;
}

void ParamFurtherSetup(StepperMotorController *self)
{
    self->mcu->param_pwm_period_s = self->param_pwm_period_s;
    self->controller->param_pos_control_period_s = self->param_pos_control_period_s;
    self->controller->param_cur_control_period_s = self->param_cur_control_period_s;
    self->mcu->param_task_period_s = self->param_task_period_s;

    self->controller->param_motor_R = self->stepper_motor->param_R + self->driver_board->param_mos_Ron;
    self->controller->param_motor_L = self->stepper_motor->param_L;
    self->controller->fwc.param_L = self->stepper_motor->param_L;
    self->controller->fwc.param_phi_e = self->stepper_motor->param_Ke / self->stepper_motor->param_pole_pair;
    self->controller->fwc.param_pole_pair = self->stepper_motor->param_pole_pair;

    // self->controller->leso.param_b0 = self->controller->leso.param_b0k * self->stepper_motor->param_Kt / self->stepper_motor->param_J;
    self->controller->leso.param_b0 = self->controller->leso.param_b0k * 6000;

    self->step_controller.param_single_turn_mode = self->param_singleturn_control_mode;
    self->encoder->param_single_turn_mode = self->param_singleturn_control_mode;
    self->controller->param_single_turn_mode = self->param_singleturn_control_mode;
    self->controller->td.param_single_turn_mode = self->param_singleturn_control_mode;
    self->controller->leso.param_single_turn_mode = self->param_singleturn_control_mode;

    self->mcu->param_input_pulse_counter_period_count = self->step_controller.param_pulse_count_max - 1;

    /* protection param */
    self->protection.param_check_period_s = self->param_task_period_s;
    self->protection.param_encoder_mutation_upper_encoder_pulse = (int32_t)(self->encoder->param_encoder_max_pulse * self->protection.param_encoder_mutation_coefficient_upper);
    self->protection.param_encoder_mutation_lower_encoder_pulse = (int32_t)(self->encoder->param_encoder_max_pulse * self->protection.param_encoder_mutation_coefficient_lower);

    /* system id */
    self->system_id_RL.param_Ts = self->param_cur_control_period_s;

    /* zazen mode */
    self->zazen_mode.param_Ts = self->param_task_period_s;
}

void DefaultParam_Init_default(StepperMotorController *self)
{
    memset(self, 0, sizeof(StepperMotorController));

    /* Init stepper_motor_controller */
    self->ConfigParam = DefaultParam_Init_default;
    self->Init = StepperMotorController_Init;
    self->driver_board = &driver_board_motor_drv42_v11;
    self->stepper_motor = &stepper_motor_default;
    self->encoder = &encoder_MT6826_15bit;
    self->mcu = &mcu_ch32v303CBT6_v11;
    self->controller = &controller_default;
    // self->controller = &controller_ParallelLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    // self->controller = &controller_FhanLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    self->flash_manager_param = &flash_manager_param_v1_0;
    self->param_firmware_version.number.all = (((uint32_t)FIRMWARE_VERSION_MAJOR << 24) | ((uint32_t)FIRMWARE_VERSION_MINOR << 16) | ((uint32_t)FIRMWARE_VERSION_PATCH << 8) | ((uint32_t)FIRMWARE_VERSION_COMPILED));
    self->param_firmware_version.release_date = FIRMWARE_RELEASE_DATE;
    self->param_boot_key = BOOT_SKIP_KEY;
    // self->flash_manager_encoder_table = &flash_manager_encoder_calibration;
    self->logger = &logger_v1_0;

    self->param_flash_key_write_retries_num = 5;

    self->param_system_startup_delay_ms = 100;

    self->param_pwm_period_s = 3.5e-5;
    self->param_task_period_s = 14e-5;

    self->param_use_default_param = FALSE;
    self->param_singleturn_control_mode = TRUE;

    /** elec angle offset */
    self->param_elec_angle_calibration_standar_deg = 15.0F;
    self->param_elec_offset = 158.32; // default

    self->param_phase_order_invert = 1;

    /** rotor block dec */
    self->param_emergency_pin_mode = Emergency_Pin_Mode_Stall;
    self->param_stall_mode = StallMode_Pos;
    self->param_stall_cur_A = 0.7;
    self->param_stall_pos_err_rad = 0.015;
    
    /* dir of elec offset calibration and encoder_calibtate_official */
    self->param_calibration_dir = -1;

    /* param of encoder calibration and zero offset calibration */
    self->param_encoder_cal_count_max = 200;
    self->param_encoder_read_count = 10;
    self->param_delay_ms_per_step = 10;
    self->param_delay_ms_per_read = 1;
    self->param_ud_cal_set = 0.15;
    self->param_motion_dir = 1;

    /* encoder calibrate official */
    self->param_encoder_calibtate_official_cal_count_max = 200 * 32;
    self->param_encoder_calibtate_official_ud_cal_set = 0.15;
    self->param_encoder_calibration_round_count = 40;

    /* config module */
    self->stepper_motor->ConfigParam(self->stepper_motor);
    self->encoder->ConfigParam(self->encoder);
    self->mcu->ConfigParam(self->mcu);
    self->controller->ConfigParam(self->controller);
    self->driver_board->ConfigParam(self->driver_board);
    self->flash_manager_param->ConfigParam(self->flash_manager_param);
    // self->flash_manager_encoder_table->ConfigParam(self->flash_manager_encoder_table);
    self->logger->ConfigParam(self->logger);
    PeriodCorrect(self);

    /* connect module */
    self->driver_board->mcu = self->mcu;
    self->encoder->mcu = self->mcu;
    self->controller->motor = self->stepper_motor;
    self->step_controller.mcu = self->mcu;
    self->flash_manager_param->mcu = self->mcu;
    self->logger->mcu = self->mcu;

    /*** module param settings ***/
    /* Protection */
    self->protection.Init = Protection_Init;
    self->protection.param_version.number.all = (((uint16_t)PROTECTION_VERSION_MAJOR << 8) | ((uint16_t)PROTECTION_VERSION_MINOR));
    self->protection.param_version.release_date = PROTECTION_RELEASE_DATE;
    self->protection.param_en = 0;
    self->protection.param_enable_report = 0;
    // self->protection.param_check_period_s = self->param_task_period_s;
    self->protection.param_err_code_mask = 0xffffffff;
    self->protection.param_warning_code_mask = 0xffffffff;
    self->protection.param_encoder_mutation_coefficient_upper = 0.5;
    self->protection.param_encoder_mutation_coefficient_lower = 0.1;
    self->protection.param_peak_overcurrent_A = 999.0;
    self->protection.param_continuous_overcurrent_A = 4.0;
    self->protection.param_continuous_overcurrent_time_s = 2.0;
    self->protection.param_speed_over_limit_rad_s = 3000 * RPM2RAD;
    self->protection.param_speed_over_limit_time_s = 0.1;
    self->protection.param_pos_over_limit_max_rad = 999;
    self->protection.param_pos_over_limit_min_rad = -999;
    self->protection.param_pos_cmd_mutation_turns = 0.1;
    self->protection.param_pos_tracking_error_maximum_rad = 0.3;
    self->protection.param_pos_tracking_error_time_s = 0.1;
    self->protection.param_power_voltage_min = 20.0;
    self->protection.param_mcu_temp_max = 115.0;

    /* Chopper param */
    self->chopper.Init = Chopper_Init;
    self->chopper.param_chopper_mode = ChopperMode_SlowDecay;
    self->chopper.param_svpwm_mode = SVPWMMode_2phase8vector;
    self->chopper.param_base_pwm = 0.0;
    self->chopper.param_offset_pwm_en = 0;
    self->chopper.param_offset_pwm = 0.02;
    self->chopper.param_hybrid_decay_ratio = 99999999;

    /* StepController param */
    self->step_controller.Init = StepController_Init;
    self->step_controller.param_pulse_count_max = 65000;
    self->step_controller.param_subdivision = 16;
    self->step_controller.param_pulse_trim_en = 0;
    self->step_controller.param_trim_action_period = 10;
    self->step_controller.param_extra_trim_pulse = 10;

    /* S Curve Init */
    // self->scurve.Init = SCurve_Init;
    // self->scurve.param_period_s = 0.02;
    // self->scurve.param_acc_max = 10;
    // self->scurve.param_speed_max = 100;
    // self->scurve.param_jerk = 1000;

    /* CommunicationInterface */
    self->communication_interface.Init = CommunicationInterface_Init;
    self->communication_interface.param_version.number.all = (((uint16_t)CMD_SYSTEM_VERSION_MAJOR << 8) | ((uint16_t)CMD_SYSTEM_VERSION_MINOR));
    self->communication_interface.param_version.release_date = CMD_SYSTEM_RELEASE_DATE;
    self->communication_interface.param_char_cmd_support = TRUE;
    self->communication_interface.param_slave_addr = SlaveAddr_Invalid;
    self->communication_interface.param_receive_buff_addr = UartRxBuff;
    self->communication_interface.period_s = 0.02;
    self->communication_interface.param_data_frame_head_master = 0xff;
    self->communication_interface.param_data_frame_head_slave = 0xee;

    /* system id */
    // self->system_id_RL.param_Ts = self->param_cur_control_period_s;
    float uin_tmp[5] = {0.06, 0.15, 0.13, 0.3, 0.4};
    memcpy(self->system_id_RL.param_uin_series, uin_tmp, sizeof(uin_tmp));
    self->system_id_RL.param_current_stable_err_condition = 0.0005;
    self->system_id_RL.param_current_buff_size = 300;
    self->system_id_RL.param_current_err_size = 20;
    self->system_id_RL.param_prepare_time = 5000;
    self->system_id_RL.param_normal_R_range_min = 0.1;
    self->system_id_RL.param_normal_R_range_max = 100;
    self->system_id_RL.param_normal_L_range_min = 1e-6;
    self->system_id_RL.param_normal_L_range_max = 1000000e-6;

    /* motor phase check */
    self->motor_phase_check.param_run_on_startup = 1;
    self->motor_phase_check.param_motor_resistance_tolerance_standar_percent = 30;

    /* zazen mode */
    self->zazen_mode.param_en = 0;
    self->zazen_mode.param_trigger_time_s = 1.0;
    self->zazen_mode.param_gain.pos_kp = 1.0;
    self->zazen_mode.param_gain.spd_kp = 0.5;
    self->zazen_mode.param_gain.spd_ki = 0.5;
    self->zazen_mode.param_gain.cur_kp = 0.5;
    self->zazen_mode.param_gain.cur_ki = 0.5;

    /* param settings */
    ParamFurtherSetup(self);
}

void DefaultParam_Init_Red_X(StepperMotorController *self)
{
    memset(self, 0, sizeof(StepperMotorController));

    /* Init stepper_motor_controller */
    self->ConfigParam = DefaultParam_Init_Red_X;
    self->Init = StepperMotorController_Init;
    self->driver_board = &driver_board_motor_drv42_v12;
    self->stepper_motor = &stepper_motor_Moons_4248_MS17HDB3P4250;
    self->encoder = &encoder_MT6835_21bit;
    self->mcu = &mcu_ch32v303CBT6_v12;
    self->controller = &controller_default;
    // self->controller = &controller_ParallelLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    // self->controller = &controller_FhanLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    self->flash_manager_param = &flash_manager_param_v1_0;
    self->param_firmware_version.number.all = (((uint32_t)FIRMWARE_VERSION_MAJOR << 24) | ((uint32_t)FIRMWARE_VERSION_MINOR << 16) | ((uint32_t)FIRMWARE_VERSION_PATCH << 8) | ((uint32_t)FIRMWARE_VERSION_COMPILED));
    self->param_firmware_version.release_date = FIRMWARE_RELEASE_DATE;
    self->param_boot_key = BOOT_SKIP_KEY;
    // self->flash_manager_encoder_table = &flash_manager_encoder_calibration;
    self->logger = &logger_v1_0;

    self->param_flash_key_write_retries_num = 5;

    self->param_system_startup_delay_ms = 100;

    self->param_pwm_period_s = 3.5e-5;
    self->param_task_period_s = 14e-5;

    self->param_use_default_param = FALSE;
    self->param_singleturn_control_mode = TRUE;

    /** elec angle offset */
    self->param_elec_angle_calibration_standar_deg = 15.0F;
    self->param_elec_offset = 738.68; //-X
    self->param_phase_order_invert = 1;

    /** rotor block dec */
    self->param_emergency_pin_mode = Emergency_Pin_Mode_Stall;
    self->param_stall_mode = StallMode_Pos;
    self->param_stall_cur_A = 1.0;
    self->param_stall_pos_err_rad = 0.015;

    /* dir of elec offset calibration and encoder_calibtate_official */
    self->param_calibration_dir = -1;

    /* param of encoder calibration and zero offset calibration */
    self->param_encoder_cal_count_max = 200;
    self->param_encoder_read_count = 10;
    self->param_delay_ms_per_step = 10;
    self->param_delay_ms_per_read = 1;
    self->param_ud_cal_set = 0.20;
    self->param_motion_dir = 1;

    /* encoder calibrate official */
    self->param_encoder_calibtate_official_cal_count_max = 200 * 32;
    self->param_encoder_calibtate_official_ud_cal_set = 0.2;
    self->param_encoder_calibration_round_count = 40;

    /* config module */
    self->stepper_motor->ConfigParam(self->stepper_motor);
    self->encoder->ConfigParam(self->encoder);
    self->mcu->ConfigParam(self->mcu);
    self->controller->ConfigParam(self->controller);
    self->driver_board->ConfigParam(self->driver_board);
    self->flash_manager_param->ConfigParam(self->flash_manager_param);
    // self->flash_manager_encoder_table->ConfigParam(self->flash_manager_encoder_table);
    self->logger->ConfigParam(self->logger);
    PeriodCorrect(self);

    /* connect module */
    self->driver_board->mcu = self->mcu;
    self->encoder->mcu = self->mcu;
    self->controller->motor = self->stepper_motor;
    self->step_controller.mcu = self->mcu;
    self->flash_manager_param->mcu = self->mcu;
    self->logger->mcu = self->mcu;

    /*** module param settings ***/
    /* Protection */
    self->protection.Init = Protection_Init;
    self->protection.param_version.number.all = (((uint16_t)PROTECTION_VERSION_MAJOR << 8) | ((uint16_t)PROTECTION_VERSION_MINOR));
    self->protection.param_version.release_date = PROTECTION_RELEASE_DATE;
    self->protection.param_en = 0;
    self->protection.param_enable_report = 0;
    // self->protection.param_check_period_s = self->param_task_period_s;
    self->protection.param_err_code_mask = 0xffffffff;
    self->protection.param_warning_code_mask = 0xffffffff;
    self->protection.param_encoder_mutation_coefficient_upper = 0.5;
    self->protection.param_encoder_mutation_coefficient_lower = 0.1;
    self->protection.param_peak_overcurrent_A = 999.0;
    self->protection.param_continuous_overcurrent_A = 4.0;
    self->protection.param_continuous_overcurrent_time_s = 5.0;
    self->protection.param_speed_over_limit_rad_s = 3000 * RPM2RAD;
    self->protection.param_speed_over_limit_time_s = 0.1;
    self->protection.param_pos_over_limit_max_rad = 999;
    self->protection.param_pos_over_limit_min_rad = -999;
    self->protection.param_pos_cmd_mutation_turns = 0.1;
    self->protection.param_pos_tracking_error_maximum_rad = 0.3;
    self->protection.param_pos_tracking_error_time_s = 0.1;
    self->protection.param_power_voltage_min = 20.0;
    self->protection.param_mcu_temp_max = 115.0;

    /* Chopper param */
    self->chopper.Init = Chopper_Init;
    self->chopper.param_chopper_mode = ChopperMode_SlowDecay;
    self->chopper.param_svpwm_mode = SVPWMMode_2phase8vector;
    self->chopper.param_base_pwm = 0.0;
    self->chopper.param_offset_pwm_en = 0;
    self->chopper.param_offset_pwm = 0.02;
    self->chopper.param_hybrid_decay_ratio = 99999999;

    /* StepController param */
    self->step_controller.Init = StepController_Init;
    self->step_controller.param_pulse_count_max = 65000;
    self->step_controller.param_subdivision = 16;
    self->step_controller.param_pulse_trim_en = 0;
    self->step_controller.param_trim_action_period = 10;
    self->step_controller.param_extra_trim_pulse = 0;

    /* S Curve Init */
    // self->scurve.Init = SCurve_Init;
    // self->scurve.param_period_s = 0.02;
    // self->scurve.param_acc_max = 10;
    // self->scurve.param_speed_max = 100;
    // self->scurve.param_jerk = 1000;

    /* CommunicationInterface */
    self->communication_interface.Init = CommunicationInterface_Init;
    self->communication_interface.param_version.number.all = (((uint16_t)CMD_SYSTEM_VERSION_MAJOR << 8) | ((uint16_t)CMD_SYSTEM_VERSION_MINOR));
    self->communication_interface.param_version.release_date = CMD_SYSTEM_RELEASE_DATE;
    self->communication_interface.param_char_cmd_support = TRUE;
    self->communication_interface.param_slave_addr = SlaveAddr_Invalid;
    self->communication_interface.param_receive_buff_addr = UartRxBuff;
    self->communication_interface.period_s = 0.02;
    self->communication_interface.param_data_frame_head_master = 0xff;
    self->communication_interface.param_data_frame_head_slave = 0xee;

    /* system id */
    // self->system_id_RL.param_Ts = self->param_cur_control_period_s;
    float uin_tmp[5] = {0.06, 0.15, 0.13, 0.3, 0.4};
    memcpy(self->system_id_RL.param_uin_series, uin_tmp, sizeof(uin_tmp));
    self->system_id_RL.param_current_stable_err_condition = 0.0005;
    self->system_id_RL.param_current_buff_size = 300;
    self->system_id_RL.param_current_err_size = 20;
    self->system_id_RL.param_prepare_time = 5000;
    self->system_id_RL.param_normal_R_range_min = 0.1;
    self->system_id_RL.param_normal_R_range_max = 100;
    self->system_id_RL.param_normal_L_range_min = 1e-6;
    self->system_id_RL.param_normal_L_range_max = 1000000e-6;

    /* motor phase check */
    self->motor_phase_check.param_run_on_startup = 1;
    self->motor_phase_check.param_motor_resistance_tolerance_standar_percent = 30;

    /* zazen mode */
    self->zazen_mode.param_en = 0;
    self->zazen_mode.param_trigger_time_s = 1.0;
    self->zazen_mode.param_gain.pos_kp = 1.0;
    self->zazen_mode.param_gain.spd_kp = 0.5;
    self->zazen_mode.param_gain.spd_ki = 0.5;
    self->zazen_mode.param_gain.cur_kp = 0.5;
    self->zazen_mode.param_gain.cur_ki = 0.5;

    /* param settings */
    ParamFurtherSetup(self);
}

void DefaultParam_Init_Red_Y(StepperMotorController *self)
{
    memset(self, 0, sizeof(StepperMotorController));

    /* Init stepper_motor_controller */
    self->ConfigParam = DefaultParam_Init_Red_Y;
    self->Init = StepperMotorController_Init;
    self->driver_board = &driver_board_motor_drv42_v12;
    self->stepper_motor = &stepper_motor_Moons_4248_MS17HDB3P4250;
    self->encoder = &encoder_MT6835_21bit;
    self->mcu = &mcu_ch32v303CBT6_v12;
    self->controller = &controller_default;
    // self->controller = &controller_ParallelLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    // self->controller = &controller_FhanLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    self->flash_manager_param = &flash_manager_param_v1_0;
    self->param_firmware_version.number.all = (((uint32_t)FIRMWARE_VERSION_MAJOR << 24) | ((uint32_t)FIRMWARE_VERSION_MINOR << 16) | ((uint32_t)FIRMWARE_VERSION_PATCH << 8) | ((uint32_t)FIRMWARE_VERSION_COMPILED));
    self->param_firmware_version.release_date = FIRMWARE_RELEASE_DATE;
    self->param_boot_key = BOOT_SKIP_KEY;
    // self->flash_manager_encoder_table = &flash_manager_encoder_calibration;
    self->logger = &logger_v1_0;

    self->param_flash_key_write_retries_num = 5;

    self->param_system_startup_delay_ms = 100;

    self->param_pwm_period_s = 3.5e-5;
    self->param_task_period_s = 14e-5;

    self->param_use_default_param = FALSE;
    self->param_singleturn_control_mode = TRUE;

    /** elec angle offset */
    self->param_elec_angle_calibration_standar_deg = 15.0F;
    self->param_elec_offset = 675.44; //-Y
    self->param_phase_order_invert = 1;

    /** rotor block dec */
    self->param_emergency_pin_mode = Emergency_Pin_Mode_Stall;
    self->param_stall_mode = StallMode_Pos;
    self->param_stall_cur_A = 1.1;
    self->param_stall_pos_err_rad = 0.015;

    /* dir of elec offset calibration and encoder_calibtate_official */
    self->param_calibration_dir = -1;

    /* param of encoder calibration and zero offset calibration */
    self->param_encoder_cal_count_max = 200;
    self->param_encoder_read_count = 10;
    self->param_delay_ms_per_step = 10;
    self->param_delay_ms_per_read = 1;
    self->param_ud_cal_set = 0.20;
    self->param_motion_dir = 1;

    /* encoder calibrate official */
    self->param_encoder_calibtate_official_cal_count_max = 200 * 32;
    self->param_encoder_calibtate_official_ud_cal_set = 0.2;
    self->param_encoder_calibration_round_count = 40;

    /* config module */
    self->stepper_motor->ConfigParam(self->stepper_motor);
    self->encoder->ConfigParam(self->encoder);
    self->mcu->ConfigParam(self->mcu);
    self->controller->ConfigParam(self->controller);
    self->driver_board->ConfigParam(self->driver_board);
    self->flash_manager_param->ConfigParam(self->flash_manager_param);
    // self->flash_manager_encoder_table->ConfigParam(self->flash_manager_encoder_table);
    self->logger->ConfigParam(self->logger);
    PeriodCorrect(self);

    /* connect module */
    self->driver_board->mcu = self->mcu;
    self->encoder->mcu = self->mcu;
    self->controller->motor = self->stepper_motor;
    self->step_controller.mcu = self->mcu;
    self->flash_manager_param->mcu = self->mcu;
    self->logger->mcu = self->mcu;

    /*** module param settings ***/
    /* Protection */
    self->protection.Init = Protection_Init;
    self->protection.param_version.number.all = (((uint16_t)PROTECTION_VERSION_MAJOR << 8) | ((uint16_t)PROTECTION_VERSION_MINOR));
    self->protection.param_version.release_date = PROTECTION_RELEASE_DATE;
    self->protection.param_en = 0;
    self->protection.param_enable_report = 0;
    // self->protection.param_check_period_s = self->param_task_period_s;
    self->protection.param_err_code_mask = 0xffffffff;
    self->protection.param_warning_code_mask = 0xffffffff;
    self->protection.param_encoder_mutation_coefficient_upper = 0.5;
    self->protection.param_encoder_mutation_coefficient_lower = 0.1;
    self->protection.param_peak_overcurrent_A = 999.0;
    self->protection.param_continuous_overcurrent_A = 5.0;
    self->protection.param_continuous_overcurrent_time_s = 15.0;
    self->protection.param_speed_over_limit_rad_s = 3000 * RPM2RAD;
    self->protection.param_speed_over_limit_time_s = 0.1;
    self->protection.param_pos_over_limit_max_rad = 999;
    self->protection.param_pos_over_limit_min_rad = -999;
    self->protection.param_pos_cmd_mutation_turns = 0.1;
    self->protection.param_pos_tracking_error_maximum_rad = 0.3;
    self->protection.param_pos_tracking_error_time_s = 0.1;
    self->protection.param_power_voltage_min = 20.0;
    self->protection.param_mcu_temp_max = 115.0;

    /* Chopper param */
    self->chopper.Init = Chopper_Init;
    self->chopper.param_chopper_mode = ChopperMode_SlowDecay;
    self->chopper.param_svpwm_mode = SVPWMMode_2phase8vector;
    self->chopper.param_base_pwm = 0.0;
    self->chopper.param_offset_pwm_en = 0;
    self->chopper.param_offset_pwm = 0.02;
    self->chopper.param_hybrid_decay_ratio = 99999999;

    /* StepController param */
    self->step_controller.Init = StepController_Init;
    self->step_controller.param_pulse_count_max = 65000;
    self->step_controller.param_subdivision = 16;
    self->step_controller.param_pulse_trim_en = 0;
    self->step_controller.param_trim_action_period = 10;
    self->step_controller.param_extra_trim_pulse = 0;

    /* S Curve Init */
    // self->scurve.Init = SCurve_Init;
    // self->scurve.param_period_s = 0.02;
    // self->scurve.param_acc_max = 10;
    // self->scurve.param_speed_max = 100;
    // self->scurve.param_jerk = 1000;

    /* CommunicationInterface */
    self->communication_interface.Init = CommunicationInterface_Init;
    self->communication_interface.param_version.number.all = (((uint16_t)CMD_SYSTEM_VERSION_MAJOR << 8) | ((uint16_t)CMD_SYSTEM_VERSION_MINOR));
    self->communication_interface.param_version.release_date = CMD_SYSTEM_RELEASE_DATE;
    self->communication_interface.param_char_cmd_support = TRUE;
    self->communication_interface.param_slave_addr = SlaveAddr_Invalid;
    self->communication_interface.param_receive_buff_addr = UartRxBuff;
    self->communication_interface.period_s = 0.02;
    self->communication_interface.param_data_frame_head_master = 0xff;
    self->communication_interface.param_data_frame_head_slave = 0xee;

    /* system id */
    // self->system_id_RL.param_Ts = self->param_cur_control_period_s;
    float uin_tmp[5] = {0.06, 0.15, 0.13, 0.3, 0.4};
    memcpy(self->system_id_RL.param_uin_series, uin_tmp, sizeof(uin_tmp));
    self->system_id_RL.param_current_stable_err_condition = 0.0005;
    self->system_id_RL.param_current_buff_size = 300;
    self->system_id_RL.param_current_err_size = 20;
    self->system_id_RL.param_prepare_time = 5000;
    self->system_id_RL.param_normal_R_range_min = 0.1;
    self->system_id_RL.param_normal_R_range_max = 100;
    self->system_id_RL.param_normal_L_range_min = 1e-6;
    self->system_id_RL.param_normal_L_range_max = 1000000e-6;

    /* motor phase check */
    self->motor_phase_check.param_run_on_startup = 1;
    self->motor_phase_check.param_motor_resistance_tolerance_standar_percent = 30;

    /* zazen mode */
    self->zazen_mode.param_en = 0;
    self->zazen_mode.param_trigger_time_s = 1.0;
    self->zazen_mode.param_gain.pos_kp = 1.0;
    self->zazen_mode.param_gain.spd_kp = 0.5;
    self->zazen_mode.param_gain.spd_ki = 0.5;
    self->zazen_mode.param_gain.cur_kp = 0.5;
    self->zazen_mode.param_gain.cur_ki = 0.5;

    /* param settings */
    ParamFurtherSetup(self);
}

void DefaultParam_Init_PF019Pro_XY(StepperMotorController *self)
{
    memset(self, 0, sizeof(StepperMotorController));

    /* Init stepper_motor_controller */
    self->ConfigParam = DefaultParam_Init_PF019Pro_XY;
    self->Init = StepperMotorController_Init;
    self->driver_board = &driver_board_motor_drv42_v12;
    self->stepper_motor = &stepper_motor_Moons_4248_MS17HDB3P4250;
    self->encoder = &encoder_MT6835_21bit;
    self->mcu = &mcu_ch32v303CBT6_v12;
    self->controller = &controller_PF019Pro_XY;
    // self->controller = &controller_ParallelLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    // self->controller = &controller_FhanLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    self->flash_manager_param = &flash_manager_param_v1_0;
    self->param_firmware_version.number.all = (((uint32_t)FIRMWARE_VERSION_MAJOR << 24) | ((uint32_t)FIRMWARE_VERSION_MINOR << 16) | ((uint32_t)FIRMWARE_VERSION_PATCH << 8) | ((uint32_t)FIRMWARE_VERSION_COMPILED));
    self->param_firmware_version.release_date = FIRMWARE_RELEASE_DATE;
    self->param_boot_key = BOOT_SKIP_KEY;
    // self->flash_manager_encoder_table = &flash_manager_encoder_calibration;
    self->logger = &logger_v1_0;

    self->param_flash_key_write_retries_num = 5;

    self->param_system_startup_delay_ms = 100;

    self->param_pwm_period_s = 3.5e-5;
    self->param_task_period_s = 14e-5;

    self->param_use_default_param = FALSE;
    self->param_singleturn_control_mode = TRUE;

    /** elec angle offset */
    self->param_elec_angle_calibration_standar_deg = 10.0F;
    // self->param_elec_offset = 654.80;//PF008a-左
    // self->param_elec_offset = 1252.18;//PF008a-右

    self->param_elec_offset = 401.3; // default

    self->param_phase_order_invert = 1;

    /** rotor block dec */
    self->param_emergency_pin_mode = Emergency_Pin_Mode_Stall;
    self->param_stall_mode = StallMode_Pos;
    self->param_stall_cur_A = 0.7;
    self->param_stall_pos_err_rad = 0.015;

    /* dir of elec offset calibration and encoder_calibtate_official */
    self->param_calibration_dir = -1;

    /* param of encoder calibration and zero offset calibration */
    self->param_encoder_cal_count_max = 200;
    self->param_encoder_read_count = 10;
    self->param_delay_ms_per_step = 10;
    self->param_delay_ms_per_read = 1;
    self->param_ud_cal_set = 0.1;
    self->param_motion_dir = 1;

    /* encoder calibrate official */
    self->param_encoder_calibtate_official_cal_count_max = 200 * 32;
    self->param_encoder_calibtate_official_ud_cal_set = 0.1;
    self->param_encoder_calibration_round_count = 40;

    /* config module */
    self->stepper_motor->ConfigParam(self->stepper_motor);
    self->encoder->ConfigParam(self->encoder);
    self->mcu->ConfigParam(self->mcu);
    self->controller->ConfigParam(self->controller);
    self->driver_board->ConfigParam(self->driver_board);
    self->flash_manager_param->ConfigParam(self->flash_manager_param);
    // self->flash_manager_encoder_table->ConfigParam(self->flash_manager_encoder_table);
    self->logger->ConfigParam(self->logger);
    PeriodCorrect(self);

    /* connect module */
    self->driver_board->mcu = self->mcu;
    self->encoder->mcu = self->mcu;
    self->controller->motor = self->stepper_motor;
    self->step_controller.mcu = self->mcu;
    self->flash_manager_param->mcu = self->mcu;
    self->logger->mcu = self->mcu;

    /*** module param settings ***/
    /* Protection */
    self->protection.Init = Protection_Init;
    self->protection.param_version.number.all = (((uint16_t)PROTECTION_VERSION_MAJOR << 8) | ((uint16_t)PROTECTION_VERSION_MINOR));
    self->protection.param_version.release_date = PROTECTION_RELEASE_DATE;
    self->protection.param_en = 0;
    self->protection.param_enable_report = 0;
    // self->protection.param_check_period_s = self->param_task_period_s;
    self->protection.param_err_code_mask = 0xffffffff;
    self->protection.param_warning_code_mask = 0xffffffff;
    self->protection.param_encoder_mutation_coefficient_upper = 0.5;
    self->protection.param_encoder_mutation_coefficient_lower = 0.1;
    self->protection.param_peak_overcurrent_A = 999.0;
    self->protection.param_continuous_overcurrent_A = 4.0;
    self->protection.param_continuous_overcurrent_time_s = 2.0;
    self->protection.param_speed_over_limit_rad_s = 3000 * RPM2RAD;
    self->protection.param_speed_over_limit_time_s = 0.1;
    self->protection.param_pos_over_limit_max_rad = 999;
    self->protection.param_pos_over_limit_min_rad = -999;
    self->protection.param_pos_cmd_mutation_turns = 0.1;
    self->protection.param_pos_tracking_error_maximum_rad = 0.3;
    self->protection.param_pos_tracking_error_time_s = 0.1;
    self->protection.param_power_voltage_min = 20.0;
    self->protection.param_mcu_temp_max = 115.0;

    /* Chopper param */
    self->chopper.Init = Chopper_Init;
    self->chopper.param_chopper_mode = ChopperMode_SlowDecay;
    self->chopper.param_svpwm_mode = SVPWMMode_2phase8vector;
    self->chopper.param_base_pwm = 0.0;
    self->chopper.param_offset_pwm_en = 0;
    self->chopper.param_offset_pwm = 0.02;
    self->chopper.param_hybrid_decay_ratio = 99999999;

    /* StepController param */
    self->step_controller.Init = StepController_Init;
    self->step_controller.param_pulse_count_max = 65000;
    self->step_controller.param_subdivision = 16;
    self->step_controller.param_pulse_trim_en = 0;
    self->step_controller.param_trim_action_period = 10;
    self->step_controller.param_extra_trim_pulse = 10;

    /* S Curve Init */
    // self->scurve.Init = SCurve_Init;
    // self->scurve.param_period_s = 0.02;
    // self->scurve.param_acc_max = 10;
    // self->scurve.param_speed_max = 100;
    // self->scurve.param_jerk = 1000;

    /* CommunicationInterface */
    self->communication_interface.Init = CommunicationInterface_Init;
    self->communication_interface.param_version.number.all = (((uint16_t)CMD_SYSTEM_VERSION_MAJOR << 8) | ((uint16_t)CMD_SYSTEM_VERSION_MINOR));
    self->communication_interface.param_version.release_date = CMD_SYSTEM_RELEASE_DATE;
    self->communication_interface.param_char_cmd_support = TRUE;
    self->communication_interface.param_slave_addr = SlaveAddr_Invalid;
    self->communication_interface.param_receive_buff_addr = UartRxBuff;
    self->communication_interface.period_s = 0.02;
    self->communication_interface.param_data_frame_head_master = 0xff;
    self->communication_interface.param_data_frame_head_slave = 0xee;

    /* system id */
    // self->system_id_RL.param_Ts = self->param_cur_control_period_s;
    float uin_tmp[5] = {0.06, 0.15, 0.13, 0.3, 0.4};
    memcpy(self->system_id_RL.param_uin_series, uin_tmp, sizeof(uin_tmp));
    self->system_id_RL.param_current_stable_err_condition = 0.0005;
    self->system_id_RL.param_current_buff_size = 300;
    self->system_id_RL.param_current_err_size = 20;
    self->system_id_RL.param_prepare_time = 5000;
    self->system_id_RL.param_normal_R_range_min = 0.1;
    self->system_id_RL.param_normal_R_range_max = 100;
    self->system_id_RL.param_normal_L_range_min = 1e-6;
    self->system_id_RL.param_normal_L_range_max = 1000000e-6;

    /* motor phase check */
    self->motor_phase_check.param_run_on_startup = 1;
    self->motor_phase_check.param_motor_resistance_tolerance_standar_percent = 30;

    /* zazen mode */
    self->zazen_mode.param_en = 0;
    self->zazen_mode.param_trigger_time_s = 1.0;
    self->zazen_mode.param_gain.pos_kp = 1.0;
    self->zazen_mode.param_gain.spd_kp = 0.5;
    self->zazen_mode.param_gain.spd_ki = 0.5;
    self->zazen_mode.param_gain.cur_kp = 0.5;
    self->zazen_mode.param_gain.cur_ki = 0.5;

    /* param settings */
    ParamFurtherSetup(self);
}

void DefaultParam_Init_PF019Pro_Z(StepperMotorController *self)
{
    memset(self, 0, sizeof(StepperMotorController));

    /* Init stepper_motor_controller */
    self->ConfigParam = DefaultParam_Init_PF019Pro_Z;
    self->Init = StepperMotorController_Init;
    self->driver_board = &driver_board_motor_drv42_v12;
    self->stepper_motor = &stepper_motor_default; //&stepper_motor_Moons_4248_MS17HDB3P4250;
    self->encoder = &encoder_MT6826_15bit;
    self->mcu = &mcu_ch32v303CBT6_v12;
    self->controller = &controller_PF019Pro_Z;
    // self->controller = &controller_ParallelLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    // self->controller = &controller_FhanLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    self->flash_manager_param = &flash_manager_param_v1_0;
    self->param_firmware_version.number.all = (((uint32_t)FIRMWARE_VERSION_MAJOR << 24) | ((uint32_t)FIRMWARE_VERSION_MINOR << 16) | ((uint32_t)FIRMWARE_VERSION_PATCH << 8) | ((uint32_t)FIRMWARE_VERSION_COMPILED));
    self->param_firmware_version.release_date = FIRMWARE_RELEASE_DATE;
    self->param_boot_key = BOOT_SKIP_KEY;
    // self->flash_manager_encoder_table = &flash_manager_encoder_calibration;
    self->logger = &logger_v1_0;

    self->param_flash_key_write_retries_num = 5;

    self->param_system_startup_delay_ms = 100;

    self->param_pwm_period_s = 3.5e-5;
    self->param_task_period_s = 14e-5;

    self->param_use_default_param = FALSE;
    self->param_singleturn_control_mode = TRUE;

    /** elec angle offset */
    self->param_elec_angle_calibration_standar_deg = 15.0F;

    self->param_elec_offset = 152.32; // default

    self->param_phase_order_invert = 1;

    /** rotor block dec */
    self->param_emergency_pin_mode = Emergency_Pin_Mode_Stall;
    self->param_stall_mode = StallMode_Pos;
    self->param_stall_cur_A = 0.7;
    self->param_stall_pos_err_rad = 0.015;

    /* dir of elec offset calibration and encoder_calibtate_official */
    self->param_calibration_dir = -1;

    /* param of encoder calibration and zero offset calibration */
    self->param_encoder_cal_count_max = 200;
    self->param_encoder_read_count = 10;
    self->param_delay_ms_per_step = 10;
    self->param_delay_ms_per_read = 1;
    self->param_ud_cal_set = 0.15;
    self->param_motion_dir = 1;

    /* encoder calibrate official */
    self->param_encoder_calibtate_official_cal_count_max = 200 * 32;
    self->param_encoder_calibtate_official_ud_cal_set = 0.15;
    self->param_encoder_calibration_round_count = 40;

    /* config module */
    self->stepper_motor->ConfigParam(self->stepper_motor);
    self->encoder->ConfigParam(self->encoder);
    self->mcu->ConfigParam(self->mcu);
    self->controller->ConfigParam(self->controller);
    self->driver_board->ConfigParam(self->driver_board);
    self->flash_manager_param->ConfigParam(self->flash_manager_param);
    // self->flash_manager_encoder_table->ConfigParam(self->flash_manager_encoder_table);
    self->logger->ConfigParam(self->logger);
    PeriodCorrect(self);

    /* connect module */
    self->driver_board->mcu = self->mcu;
    self->encoder->mcu = self->mcu;
    self->controller->motor = self->stepper_motor;
    self->step_controller.mcu = self->mcu;
    self->flash_manager_param->mcu = self->mcu;
    self->logger->mcu = self->mcu;

    /*** module param settings ***/
    /* Protection */
    self->protection.Init = Protection_Init;
    self->protection.param_version.number.all = (((uint16_t)PROTECTION_VERSION_MAJOR << 8) | ((uint16_t)PROTECTION_VERSION_MINOR));
    self->protection.param_version.release_date = PROTECTION_RELEASE_DATE;
    self->protection.param_en = 0;
    self->protection.param_enable_report = 0;
    // self->protection.param_check_period_s = self->param_task_period_s;
    self->protection.param_err_code_mask = 0xffffffff;
    self->protection.param_warning_code_mask = 0xffffffff;
    self->protection.param_encoder_mutation_coefficient_upper = 0.5;
    self->protection.param_encoder_mutation_coefficient_lower = 0.1;
    self->protection.param_peak_overcurrent_A = 999.0;
    self->protection.param_continuous_overcurrent_A = 4.0;
    self->protection.param_continuous_overcurrent_time_s = 2.0;
    self->protection.param_speed_over_limit_rad_s = 3000 * RPM2RAD;
    self->protection.param_speed_over_limit_time_s = 0.1;
    self->protection.param_pos_over_limit_max_rad = 999;
    self->protection.param_pos_over_limit_min_rad = -999;
    self->protection.param_pos_cmd_mutation_turns = 0.1;
    self->protection.param_pos_tracking_error_maximum_rad = 0.3;
    self->protection.param_pos_tracking_error_time_s = 0.1;
    self->protection.param_power_voltage_min = 20.0;
    self->protection.param_mcu_temp_max = 115.0;

    /* Chopper param */
    self->chopper.Init = Chopper_Init;
    self->chopper.param_chopper_mode = ChopperMode_SlowDecay;
    self->chopper.param_svpwm_mode = SVPWMMode_2phase8vector;
    self->chopper.param_base_pwm = 0.0;
    self->chopper.param_offset_pwm_en = 0;
    self->chopper.param_offset_pwm = 0.02;
    self->chopper.param_hybrid_decay_ratio = 99999999;

    /* StepController param */
    self->step_controller.Init = StepController_Init;
    self->step_controller.param_pulse_count_max = 65000;
    self->step_controller.param_subdivision = 16;
    self->step_controller.param_pulse_trim_en = 0;
    self->step_controller.param_trim_action_period = 10;
    self->step_controller.param_extra_trim_pulse = 10;

    /* S Curve Init */
    // self->scurve.Init = SCurve_Init;
    // self->scurve.param_period_s = 0.02;
    // self->scurve.param_acc_max = 10;
    // self->scurve.param_speed_max = 100;
    // self->scurve.param_jerk = 1000;

    /* CommunicationInterface */
    self->communication_interface.Init = CommunicationInterface_Init;
    self->communication_interface.param_version.number.all = (((uint16_t)CMD_SYSTEM_VERSION_MAJOR << 8) | ((uint16_t)CMD_SYSTEM_VERSION_MINOR));
    self->communication_interface.param_version.release_date = CMD_SYSTEM_RELEASE_DATE;
    self->communication_interface.param_char_cmd_support = TRUE;
    self->communication_interface.param_slave_addr = SlaveAddr_Invalid;
    self->communication_interface.param_receive_buff_addr = UartRxBuff;
    self->communication_interface.period_s = 0.02;
    self->communication_interface.param_data_frame_head_master = 0xff;
    self->communication_interface.param_data_frame_head_slave = 0xee;

    /* system id */
    // self->system_id_RL.param_Ts = self->param_cur_control_period_s;
    float uin_tmp[5] = {0.06, 0.15, 0.13, 0.3, 0.4};
    memcpy(self->system_id_RL.param_uin_series, uin_tmp, sizeof(uin_tmp));
    self->system_id_RL.param_current_stable_err_condition = 0.0005;
    self->system_id_RL.param_current_buff_size = 300;
    self->system_id_RL.param_current_err_size = 20;
    self->system_id_RL.param_prepare_time = 5000;
    self->system_id_RL.param_normal_R_range_min = 0.1;
    self->system_id_RL.param_normal_R_range_max = 100;
    self->system_id_RL.param_normal_L_range_min = 1e-6;
    self->system_id_RL.param_normal_L_range_max = 1000000e-6;

    /* motor phase check */
    self->motor_phase_check.param_run_on_startup = 1;
    self->motor_phase_check.param_motor_resistance_tolerance_standar_percent = 30;

    /* zazen mode */
    self->zazen_mode.param_en = 0;
    self->zazen_mode.param_trigger_time_s = 1.0;
    self->zazen_mode.param_gain.pos_kp = 1.0;
    self->zazen_mode.param_gain.spd_kp = 0.5;
    self->zazen_mode.param_gain.spd_ki = 0.5;
    self->zazen_mode.param_gain.cur_kp = 0.5;
    self->zazen_mode.param_gain.cur_ki = 0.5;

    /* param settings */
    ParamFurtherSetup(self);
}

void DefaultParam_Init_PF019Pro_E(StepperMotorController *self)
{
    memset(self, 0, sizeof(StepperMotorController));

    /* Init stepper_motor_controller */
    self->ConfigParam = DefaultParam_Init_PF019Pro_E;
    self->Init = StepperMotorController_Init;
    self->driver_board = &driver_board_motor_drv42_v11;
    self->stepper_motor = &stepper_motor_Corier_BJY36D12_04V21;
    self->encoder = &encoder_MT6835_21bit;
    self->mcu = &mcu_ch32v303CBT6_v11; //&mcu_ch32v303CBT6_v12;//
    self->controller = &controller_PF019Pro_E;
    // self->controller = &controller_ParallelLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    // self->controller = &controller_FhanLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    self->flash_manager_param = &flash_manager_param_v1_0;
    self->param_firmware_version.number.all = (((uint32_t)FIRMWARE_VERSION_MAJOR << 24) | ((uint32_t)FIRMWARE_VERSION_MINOR << 16) | ((uint32_t)FIRMWARE_VERSION_PATCH << 8) | ((uint32_t)FIRMWARE_VERSION_COMPILED));
    self->param_firmware_version.release_date = FIRMWARE_RELEASE_DATE;
    self->param_boot_key = BOOT_SKIP_KEY;
    // self->flash_manager_encoder_table = &flash_manager_encoder_calibration;
    self->logger = &logger_v1_0;

    self->param_flash_key_write_retries_num = 5;

    self->param_system_startup_delay_ms = 100;

    self->param_pwm_period_s = 3.5e-5;
    self->param_task_period_s = 14e-5;

    self->param_use_default_param = FALSE;
    self->param_singleturn_control_mode = TRUE;

    /** elec angle offset */
    self->param_elec_angle_calibration_standar_deg = 15.0F;
    self->param_elec_offset = 223.0;
    self->param_phase_order_invert = 0;

    /** rotor block dec */
    self->param_emergency_pin_mode = Emergency_Pin_Mode_Stall;
    self->param_stall_mode = StallMode_Pos;
    self->param_stall_cur_A = 0.7;
    self->param_stall_pos_err_rad = 0.015;

    /* dir of elec offset calibration and encoder_calibtate_official */
    self->param_calibration_dir = -1;

    /* param of encoder calibration and zero offset calibration */
    self->param_encoder_cal_count_max = 200;
    self->param_encoder_read_count = 10;
    self->param_delay_ms_per_step = 10;
    self->param_delay_ms_per_read = 1;
    self->param_ud_cal_set = 0.20;
    self->param_motion_dir = 1;

    /* encoder calibrate official */
    self->param_encoder_calibtate_official_cal_count_max = 200 * 32;
    self->param_encoder_calibtate_official_ud_cal_set = 0.2;
    self->param_encoder_calibration_round_count = 40;

    /* config module */
    self->stepper_motor->ConfigParam(self->stepper_motor);
    self->encoder->ConfigParam(self->encoder);
    self->mcu->ConfigParam(self->mcu);
    self->controller->ConfigParam(self->controller);
    self->driver_board->ConfigParam(self->driver_board);
    self->flash_manager_param->ConfigParam(self->flash_manager_param);
    // self->flash_manager_encoder_table->ConfigParam(self->flash_manager_encoder_table);
    self->logger->ConfigParam(self->logger);
    PeriodCorrect(self);

    /* connect module */
    self->driver_board->mcu = self->mcu;
    self->encoder->mcu = self->mcu;
    self->controller->motor = self->stepper_motor;
    self->step_controller.mcu = self->mcu;
    self->flash_manager_param->mcu = self->mcu;
    self->logger->mcu = self->mcu;

    /*** module param settings ***/
    /* Protection */
    self->protection.Init = Protection_Init;
    self->protection.param_version.number.all = (((uint16_t)PROTECTION_VERSION_MAJOR << 8) | ((uint16_t)PROTECTION_VERSION_MINOR));
    self->protection.param_version.release_date = PROTECTION_RELEASE_DATE;
    self->protection.param_en = 0;
    self->protection.param_enable_report = 0;
    // self->protection.param_check_period_s = self->param_task_period_s;
    self->protection.param_err_code_mask = 0xffffffff;
    self->protection.param_warning_code_mask = 0xffffffff;
    self->protection.param_encoder_mutation_coefficient_upper = 0.5;
    self->protection.param_encoder_mutation_coefficient_lower = 0.1;
    self->protection.param_peak_overcurrent_A = 999.0;
    self->protection.param_continuous_overcurrent_A = 2.0;
    self->protection.param_continuous_overcurrent_time_s = 5.0;
    self->protection.param_speed_over_limit_rad_s = 3000 * RPM2RAD;
    self->protection.param_speed_over_limit_time_s = 0.1;
    self->protection.param_pos_over_limit_max_rad = 999;
    self->protection.param_pos_over_limit_min_rad = -999;
    self->protection.param_pos_cmd_mutation_turns = 0.1;
    self->protection.param_pos_tracking_error_maximum_rad = 0.3;
    self->protection.param_pos_tracking_error_time_s = 0.1;
    self->protection.param_power_voltage_min = 20.0;
    self->protection.param_mcu_temp_max = 115.0;

    /* Chopper param */
    self->chopper.Init = Chopper_Init;
    self->chopper.param_chopper_mode = ChopperMode_SlowDecay;
    self->chopper.param_svpwm_mode = SVPWMMode_2phase8vector;
    self->chopper.param_base_pwm = 0.0;
    self->chopper.param_offset_pwm_en = 0;
    self->chopper.param_offset_pwm = 0.02;
    self->chopper.param_hybrid_decay_ratio = 99999999;

    /* StepController param */
    self->step_controller.Init = StepController_Init;
    self->step_controller.param_pulse_count_max = 65000;
    self->step_controller.param_subdivision = 16;
    self->step_controller.param_pulse_trim_en = 0;
    self->step_controller.param_trim_action_period = 10;
    self->step_controller.param_extra_trim_pulse = 0;

    /* S Curve Init */
    // self->scurve.Init = SCurve_Init;
    // self->scurve.param_period_s = 0.02;
    // self->scurve.param_acc_max = 10;
    // self->scurve.param_speed_max = 100;
    // self->scurve.param_jerk = 1000;

    /* CommunicationInterface */
    self->communication_interface.Init = CommunicationInterface_Init;
    self->communication_interface.param_version.number.all = (((uint16_t)CMD_SYSTEM_VERSION_MAJOR << 8) | ((uint16_t)CMD_SYSTEM_VERSION_MINOR));
    self->communication_interface.param_version.release_date = CMD_SYSTEM_RELEASE_DATE;
    self->communication_interface.param_char_cmd_support = TRUE;
    self->communication_interface.param_slave_addr = SlaveAddr_Invalid;
    self->communication_interface.param_receive_buff_addr = UartRxBuff;
    self->communication_interface.period_s = 0.02;
    self->communication_interface.param_data_frame_head_master = 0xff;
    self->communication_interface.param_data_frame_head_slave = 0xee;

    /* system id */
    // self->system_id_RL.param_Ts = self->param_cur_control_period_s;
    float uin_tmp[5] = {0.06, 0.15, 0.13, 0.3, 0.4};
    memcpy(self->system_id_RL.param_uin_series, uin_tmp, sizeof(uin_tmp));
    self->system_id_RL.param_current_stable_err_condition = 0.0005;
    self->system_id_RL.param_current_buff_size = 300;
    self->system_id_RL.param_current_err_size = 20;
    self->system_id_RL.param_prepare_time = 5000;
    self->system_id_RL.param_normal_R_range_min = 0.1;
    self->system_id_RL.param_normal_R_range_max = 100;
    self->system_id_RL.param_normal_L_range_min = 1e-6;
    self->system_id_RL.param_normal_L_range_max = 1000000e-6;

    /* motor phase check */
    self->motor_phase_check.param_run_on_startup = 1;
    self->motor_phase_check.param_motor_resistance_tolerance_standar_percent = 30;

    /* zazen mode */
    self->zazen_mode.param_en = 0;
    self->zazen_mode.param_trigger_time_s = 1.0;
    self->zazen_mode.param_gain.pos_kp = 1.0;
    self->zazen_mode.param_gain.spd_kp = 0.5;
    self->zazen_mode.param_gain.spd_ki = 0.5;
    self->zazen_mode.param_gain.cur_kp = 0.5;
    self->zazen_mode.param_gain.cur_ki = 0.5;

    /* param settings */
    ParamFurtherSetup(self);
}

void DefaultParam_Init_PF008Pro_XY(StepperMotorController *self)
{
    memset(self, 0, sizeof(StepperMotorController));

    /* Init stepper_motor_controller */
    self->ConfigParam = DefaultParam_Init_PF008Pro_XY;
    self->Init = StepperMotorController_Init;
    self->driver_board = &driver_board_motor_drv42_v23;
    self->stepper_motor = &stepper_motor_Moons_4248_MS17HD3L4250_02X; //&stepper_motor_Moons_4240_MS17HDB2L420D_01;//
    self->encoder = &encoder_MT6826_15bit;
    self->mcu = &mcu_ch32v303CBT6_v12;
    self->controller = &controller_PF008Pro_XY;
    // self->controller = &controller_ParallelLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    // self->controller = &controller_FhanLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    self->flash_manager_param = &flash_manager_param_v1_0;
    self->param_firmware_version.number.all = (((uint32_t)FIRMWARE_VERSION_MAJOR << 24) | ((uint32_t)FIRMWARE_VERSION_MINOR << 16) | ((uint32_t)FIRMWARE_VERSION_PATCH << 8) | ((uint32_t)FIRMWARE_VERSION_COMPILED));
    self->param_firmware_version.release_date = FIRMWARE_RELEASE_DATE;
    self->param_boot_key = BOOT_SKIP_KEY;
    // self->flash_manager_encoder_table = &flash_manager_encoder_calibration;
    self->logger = &logger_v1_0;

    self->param_flash_key_write_retries_num = 5;

    self->param_system_startup_delay_ms = 100;

    self->param_pwm_period_s = 3.5e-5;
    self->param_task_period_s = 3.5e-5 * 4;

    self->param_use_default_param = FALSE;
    self->param_singleturn_control_mode = TRUE;

    /** elec angle offset */
    self->param_elec_angle_calibration_standar_deg = 15.0F;
    // self->param_elec_offset = 654.80;//PF008a-左
    // self->param_elec_offset = 1252.18;//PF008a-右

    self->param_elec_offset = 0; // default

    self->param_phase_order_invert = 0;

    /** rotor block dec */
    self->param_emergency_pin_mode = Emergency_Pin_Mode_Stall;
    self->param_stall_mode = StallMode_Pos;
    self->param_stall_cur_A = 0.70;
    self->param_stall_pos_err_rad = 0.015;

    /* dir of elec offset calibration and encoder_calibtate_official */
    self->param_calibration_dir = -1;

    /* param of encoder calibration and zero offset calibration */
    self->param_encoder_cal_count_max = 200;
    self->param_encoder_read_count = 10;
    self->param_delay_ms_per_step = 10;
    self->param_delay_ms_per_read = 1;
    self->param_ud_cal_set = 0.15;
    self->param_motion_dir = 1;

    /* encoder calibrate official */
    self->param_encoder_calibtate_official_cal_count_max = 200 * 32;
    self->param_encoder_calibtate_official_ud_cal_set = 0.15;
    self->param_encoder_calibration_round_count = 40;

    /* config module */
    self->stepper_motor->ConfigParam(self->stepper_motor);
    self->encoder->ConfigParam(self->encoder);
    self->mcu->ConfigParam(self->mcu);
    self->controller->ConfigParam(self->controller);
    self->driver_board->ConfigParam(self->driver_board);
    self->flash_manager_param->ConfigParam(self->flash_manager_param);
    // self->flash_manager_encoder_table->ConfigParam(self->flash_manager_encoder_table);
    self->logger->ConfigParam(self->logger);
    PeriodCorrect(self);

    /* connect module */
    self->driver_board->mcu = self->mcu;
    self->encoder->mcu = self->mcu;
    self->controller->motor = self->stepper_motor;
    self->step_controller.mcu = self->mcu;
    self->flash_manager_param->mcu = self->mcu;
    self->logger->mcu = self->mcu;

    /*** module param settings ***/
    /* Protection */
    self->protection.Init = Protection_Init;
    self->protection.param_version.number.all = (((uint16_t)PROTECTION_VERSION_MAJOR << 8) | ((uint16_t)PROTECTION_VERSION_MINOR));
    self->protection.param_version.release_date = PROTECTION_RELEASE_DATE;
    self->protection.param_en = 1;
    self->protection.param_enable_report = 0;
    // self->protection.param_check_period_s = self->param_task_period_s;
    self->protection.param_err_code_mask = 0xffffffff & (~(PROTECTION_CODE(ERR_NUM_MOTOR_CHECK_ValueAbnormal) |
                                                           PROTECTION_CODE(ERR_NUM_MOTOR_CHECK_UnStable) |
                                                           PROTECTION_CODE(ERR_NUM_MOTOR_CHECK_MotorPhaseNotConnected) |
                                                           PROTECTION_CODE(ERR_NUM_MOTOR_CHECK_MotorPhaseResistanceDifferent) |
                                                           PROTECTION_CODE(ERR_NUM_MOTOR_CHECK_OtherErr)));
    self->protection.param_warning_code_mask = 0xffffffff;
    self->protection.param_encoder_mutation_coefficient_upper = 0.5;
    self->protection.param_encoder_mutation_coefficient_lower = 0.1;
    self->protection.param_peak_overcurrent_A = 999.0;
    self->protection.param_continuous_overcurrent_A = 4.0;
    self->protection.param_continuous_overcurrent_time_s = 1.0;
    self->protection.param_speed_over_limit_rad_s = 3000 * RPM2RAD;
    self->protection.param_speed_over_limit_time_s = 0.1;
    self->protection.param_pos_over_limit_max_rad = 999;
    self->protection.param_pos_over_limit_min_rad = -999;
    self->protection.param_pos_cmd_mutation_turns = 0.1;
    self->protection.param_pos_tracking_error_maximum_rad = 0.5;
    self->protection.param_pos_tracking_error_time_s = 0.1;
    self->protection.param_power_voltage_min = 20.0;
    self->protection.param_mcu_temp_max = 115.0;

    /* Chopper param */
    self->chopper.Init = Chopper_Init;
    self->chopper.param_chopper_mode = ChopperMode_SlowDecay; // ChopperMode_HybridDecay;//
    self->chopper.param_svpwm_mode = SVPWMMode_2phase8vector;
    self->chopper.param_base_pwm = 0.0;
    self->chopper.param_offset_pwm_en = 0;
    self->chopper.param_offset_pwm = 0.02;
    self->chopper.param_hybrid_decay_ratio = 999999999;

    /* StepController param */
    self->step_controller.Init = StepController_Init;
    self->step_controller.param_pulse_count_max = 65000;
    self->step_controller.param_subdivision = 16;
    self->step_controller.param_pulse_trim_en = 0;
    self->step_controller.param_trim_action_period = 10;
    self->step_controller.param_extra_trim_pulse = 10;

    /* S Curve Init */
    // self->scurve.Init = SCurve_Init;
    // self->scurve.param_period_s = 0.02;
    // self->scurve.param_acc_max = 10;
    // self->scurve.param_speed_max = 100;
    // self->scurve.param_jerk = 1000;

    /* CommunicationInterface */
    self->communication_interface.Init = CommunicationInterface_Init;
    self->communication_interface.param_version.number.all = (((uint16_t)CMD_SYSTEM_VERSION_MAJOR << 8) | ((uint16_t)CMD_SYSTEM_VERSION_MINOR));
    self->communication_interface.param_version.release_date = CMD_SYSTEM_RELEASE_DATE;
    self->communication_interface.param_char_cmd_support = TRUE;
    self->communication_interface.param_slave_addr = SlaveAddr_Invalid;
    self->communication_interface.param_receive_buff_addr = UartRxBuff;
    self->communication_interface.period_s = 0.02;
    self->communication_interface.param_data_frame_head_master = 0xff;
    self->communication_interface.param_data_frame_head_slave = 0xee;

    /* system id */
    // self->system_id_RL.param_Ts = self->param_cur_control_period_s;
    float uin_tmp[5] = {0.06, 0.15, 0.13, 0.3, 0.4};
    memcpy(self->system_id_RL.param_uin_series, uin_tmp, sizeof(uin_tmp));
    self->system_id_RL.param_current_stable_err_condition = 0.005;
    self->system_id_RL.param_current_buff_size = 500;
    self->system_id_RL.param_current_err_size = 20;
    self->system_id_RL.param_prepare_time = 5000;
    self->system_id_RL.param_normal_R_range_min = 0.1;
    self->system_id_RL.param_normal_R_range_max = 100;
    self->system_id_RL.param_normal_L_range_min = 1e-6;
    self->system_id_RL.param_normal_L_range_max = 1000000e-6;

    /* motor phase check */
    self->motor_phase_check.param_run_on_startup = 1;
    self->motor_phase_check.param_motor_resistance_tolerance_standar_percent = 30;

    /* zazen mode */
    self->zazen_mode.param_en = 0;
    self->zazen_mode.param_trigger_time_s = 1.0;
    self->zazen_mode.param_gain.pos_kp = 1.0;
    self->zazen_mode.param_gain.spd_kp = 0.35;
    self->zazen_mode.param_gain.spd_ki = 0.5;
    self->zazen_mode.param_gain.cur_kp = 0.5;
    self->zazen_mode.param_gain.cur_ki = 0.5;

    /* param settings */
    ParamFurtherSetup(self);
}

void DefaultParam_Init_PF008Pro_Z(StepperMotorController *self)
{
    memset(self, 0, sizeof(StepperMotorController));

    /* Init stepper_motor_controller */
    self->ConfigParam = DefaultParam_Init_PF008Pro_Z;
    self->Init = StepperMotorController_Init;
    self->driver_board = &driver_board_motor_drv42_v23;
    self->stepper_motor = &stepper_motor_Moons_4248_MS17HD3L4250_02X; //&stepper_motor_Moons_4240_MS17HDB2L420D_01;//
    self->encoder = &encoder_MT6826_15bit;
    self->mcu = &mcu_ch32v303CBT6_v12;
    self->controller = &controller_PF008Pro_Z;
    // self->controller = &controller_ParallelLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    // self->controller = &controller_FhanLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    self->flash_manager_param = &flash_manager_param_v1_0;
    self->param_firmware_version.number.all = (((uint32_t)FIRMWARE_VERSION_MAJOR << 24) | ((uint32_t)FIRMWARE_VERSION_MINOR << 16) | ((uint32_t)FIRMWARE_VERSION_PATCH << 8) | ((uint32_t)FIRMWARE_VERSION_COMPILED));
    self->param_firmware_version.release_date = FIRMWARE_RELEASE_DATE;
    self->param_boot_key = BOOT_SKIP_KEY;
    // self->flash_manager_encoder_table = &flash_manager_encoder_calibration;
    self->logger = &logger_v1_0;

    self->param_flash_key_write_retries_num = 5;

    self->param_system_startup_delay_ms = 100;

    self->param_pwm_period_s = 3.5e-5;
    self->param_task_period_s = 3.5e-5 * 4;

    self->param_use_default_param = FALSE;
    self->param_singleturn_control_mode = TRUE;

    /** elec angle offset */
    self->param_elec_angle_calibration_standar_deg = 15.0F;
    // self->param_elec_offset = 654.80;//PF008a-左
    // self->param_elec_offset = 1252.18;//PF008a-右

    self->param_elec_offset = 635.34; // default

    self->param_phase_order_invert = 0;

    /** rotor block dec */
    self->param_emergency_pin_mode = Emergency_Pin_Mode_Stall;
    self->param_stall_mode = StallMode_Pos;
    self->param_stall_cur_A = 0.70;
    self->param_stall_pos_err_rad = 0.015;

    /* dir of elec offset calibration and encoder_calibtate_official */
    self->param_calibration_dir = -1;

    /* param of encoder calibration and zero offset calibration */
    self->param_encoder_cal_count_max = 200;
    self->param_encoder_read_count = 10;
    self->param_delay_ms_per_step = 10;
    self->param_delay_ms_per_read = 1;
    self->param_ud_cal_set = 0.15;
    self->param_motion_dir = 1;

    /* encoder calibrate official */
    self->param_encoder_calibtate_official_cal_count_max = 200 * 32;
    self->param_encoder_calibtate_official_ud_cal_set = 0.15;
    self->param_encoder_calibration_round_count = 40;

    /* config module */
    self->stepper_motor->ConfigParam(self->stepper_motor);
    self->encoder->ConfigParam(self->encoder);
    self->mcu->ConfigParam(self->mcu);
    self->controller->ConfigParam(self->controller);
    self->driver_board->ConfigParam(self->driver_board);
    self->flash_manager_param->ConfigParam(self->flash_manager_param);
    // self->flash_manager_encoder_table->ConfigParam(self->flash_manager_encoder_table);
    self->logger->ConfigParam(self->logger);
    PeriodCorrect(self);

    /* connect module */
    self->driver_board->mcu = self->mcu;
    self->encoder->mcu = self->mcu;
    self->controller->motor = self->stepper_motor;
    self->step_controller.mcu = self->mcu;
    self->flash_manager_param->mcu = self->mcu;
    self->logger->mcu = self->mcu;

    /*** module param settings ***/
    /* Protection */
    self->protection.Init = Protection_Init;
    self->protection.param_version.number.all = (((uint16_t)PROTECTION_VERSION_MAJOR << 8) | ((uint16_t)PROTECTION_VERSION_MINOR));
    self->protection.param_version.release_date = PROTECTION_RELEASE_DATE;
    self->protection.param_en = 1;
    self->protection.param_enable_report = 0;
    // self->protection.param_check_period_s = self->param_task_period_s;
    self->protection.param_err_code_mask = 0xffffffff & (~(PROTECTION_CODE(ERR_NUM_MOTOR_CHECK_ValueAbnormal) |
                                                           PROTECTION_CODE(ERR_NUM_MOTOR_CHECK_UnStable) |
                                                           PROTECTION_CODE(ERR_NUM_MOTOR_CHECK_MotorPhaseNotConnected) |
                                                           PROTECTION_CODE(ERR_NUM_MOTOR_CHECK_MotorPhaseResistanceDifferent) |
                                                           PROTECTION_CODE(ERR_NUM_MOTOR_CHECK_OtherErr)));
    self->protection.param_warning_code_mask = 0xffffffff;
    self->protection.param_encoder_mutation_coefficient_upper = 0.5;
    self->protection.param_encoder_mutation_coefficient_lower = 0.1;
    self->protection.param_peak_overcurrent_A = 999.0;
    self->protection.param_continuous_overcurrent_A = 4.0;
    self->protection.param_continuous_overcurrent_time_s = 1.0;
    self->protection.param_speed_over_limit_rad_s = 3000 * RPM2RAD;
    self->protection.param_speed_over_limit_time_s = 0.1;
    self->protection.param_pos_over_limit_max_rad = 999;
    self->protection.param_pos_over_limit_min_rad = -999;
    self->protection.param_pos_cmd_mutation_turns = 0.1;
    self->protection.param_pos_tracking_error_maximum_rad = 0.1;
    self->protection.param_pos_tracking_error_time_s = 0.1;
    self->protection.param_power_voltage_min = 20.0;
    self->protection.param_mcu_temp_max = 115.0;

    /* Chopper param */
    self->chopper.Init = Chopper_Init;
    self->chopper.param_chopper_mode = ChopperMode_SlowDecay; // ChopperMode_HybridDecay;//
    self->chopper.param_svpwm_mode = SVPWMMode_2phase8vector;
    self->chopper.param_base_pwm = 0.0;
    self->chopper.param_offset_pwm_en = 0;
    self->chopper.param_offset_pwm = 0.02;
    self->chopper.param_hybrid_decay_ratio = 999999999;

    /* StepController param */
    self->step_controller.Init = StepController_Init;
    self->step_controller.param_pulse_count_max = 65000;
    self->step_controller.param_subdivision = 16;
    self->step_controller.param_pulse_trim_en = 0;
    self->step_controller.param_trim_action_period = 10;
    self->step_controller.param_extra_trim_pulse = 10;

    /* S Curve Init */
    // self->scurve.Init = SCurve_Init;
    // self->scurve.param_period_s = 0.02;
    // self->scurve.param_acc_max = 10;
    // self->scurve.param_speed_max = 100;
    // self->scurve.param_jerk = 1000;

    /* CommunicationInterface */
    self->communication_interface.Init = CommunicationInterface_Init;
    self->communication_interface.param_version.number.all = (((uint16_t)CMD_SYSTEM_VERSION_MAJOR << 8) | ((uint16_t)CMD_SYSTEM_VERSION_MINOR));
    self->communication_interface.param_version.release_date = CMD_SYSTEM_RELEASE_DATE;
    self->communication_interface.param_char_cmd_support = TRUE;
    self->communication_interface.param_slave_addr = SlaveAddr_Invalid;
    self->communication_interface.param_receive_buff_addr = UartRxBuff;
    self->communication_interface.period_s = 0.02;
    self->communication_interface.param_data_frame_head_master = 0xff;
    self->communication_interface.param_data_frame_head_slave = 0xee;

    /* system id */
    // self->system_id_RL.param_Ts = self->param_cur_control_period_s;
    float uin_tmp[5] = {0.06, 0.15, 0.13, 0.3, 0.4};
    memcpy(self->system_id_RL.param_uin_series, uin_tmp, sizeof(uin_tmp));
    self->system_id_RL.param_current_stable_err_condition = 0.005;
    self->system_id_RL.param_current_buff_size = 500;
    self->system_id_RL.param_current_err_size = 20;
    self->system_id_RL.param_prepare_time = 5000;
    self->system_id_RL.param_normal_R_range_min = 0.1;
    self->system_id_RL.param_normal_R_range_max = 100;
    self->system_id_RL.param_normal_L_range_min = 1e-6;
    self->system_id_RL.param_normal_L_range_max = 1000000e-6;

    /* motor phase check */
    self->motor_phase_check.param_run_on_startup = 1;
    self->motor_phase_check.param_motor_resistance_tolerance_standar_percent = 30;

    /* zazen mode */
    self->zazen_mode.param_en = 1;
    self->zazen_mode.param_trigger_time_s = 1.0;
    self->zazen_mode.param_gain.pos_kp = 1.0;
    self->zazen_mode.param_gain.spd_kp = 0.4;
    self->zazen_mode.param_gain.spd_ki = 0.5;
    self->zazen_mode.param_gain.cur_kp = 0.5;
    self->zazen_mode.param_gain.cur_ki = 0.5;

    /* param settings */
    ParamFurtherSetup(self);
}

void DefaultParam_Init_PF008Pro_E(StepperMotorController *self)
{
    memset(self, 0, sizeof(StepperMotorController));

    /* Init stepper_motor_controller */
    self->ConfigParam = DefaultParam_Init_PF008Pro_E;
    self->Init = StepperMotorController_Init;
    self->driver_board = &driver_board_motor_drv36_v22;
    self->stepper_motor = &stepper_motor_Corier_BJY36D12_04V21;
    self->encoder = &encoder_MT6826_15bit;
    self->mcu = &mcu_ch32v303CBT6_v11;
    self->controller = &controller_PF008Pro_E;
    // self->controller = &controller_ParallelLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    // self->controller = &controller_FhanLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    self->flash_manager_param = &flash_manager_param_v1_0;
    self->param_firmware_version.number.all = (((uint32_t)FIRMWARE_VERSION_MAJOR << 24) | ((uint32_t)FIRMWARE_VERSION_MINOR << 16) | ((uint32_t)FIRMWARE_VERSION_PATCH << 8) | ((uint32_t)FIRMWARE_VERSION_COMPILED));
    self->param_firmware_version.release_date = FIRMWARE_RELEASE_DATE;
    self->param_boot_key = BOOT_SKIP_KEY;
    // self->flash_manager_encoder_table = &flash_manager_encoder_calibration;
    self->logger = &logger_v1_0;

    self->param_flash_key_write_retries_num = 5;

    self->param_system_startup_delay_ms = 100;

    self->param_pwm_period_s = 3.5e-5;
    self->param_task_period_s = 14e-5;

    self->param_use_default_param = FALSE;
    self->param_singleturn_control_mode = TRUE;

    /** elec angle offset */
    self->param_elec_angle_calibration_standar_deg = 15.0F;

    self->param_elec_offset = 158.32; // default

    self->param_phase_order_invert = 1;

    /** rotor block dec */
    self->param_emergency_pin_mode = Emergency_Pin_Mode_Stall;
    self->param_stall_mode = StallMode_Pos;
    self->param_stall_cur_A = 0.7;
    self->param_stall_pos_err_rad = 0.015;

    /* dir of elec offset calibration and encoder_calibtate_official */
    self->param_calibration_dir = -1;

    /* param of encoder calibration and zero offset calibration */
    self->param_encoder_cal_count_max = 200;
    self->param_encoder_read_count = 10;
    self->param_delay_ms_per_step = 10;
    self->param_delay_ms_per_read = 1;
    self->param_ud_cal_set = 0.06;
    self->param_motion_dir = 1;

    /* encoder calibrate official */
    self->param_encoder_calibtate_official_cal_count_max = 200 * 32;
    self->param_encoder_calibtate_official_ud_cal_set = 0.06;
    self->param_encoder_calibration_round_count = 40;

    /* config module */
    self->stepper_motor->ConfigParam(self->stepper_motor);
    self->encoder->ConfigParam(self->encoder);
    self->mcu->ConfigParam(self->mcu);
    self->controller->ConfigParam(self->controller);
    self->driver_board->ConfigParam(self->driver_board);
    self->flash_manager_param->ConfigParam(self->flash_manager_param);
    // self->flash_manager_encoder_table->ConfigParam(self->flash_manager_encoder_table);
    self->logger->ConfigParam(self->logger);
    PeriodCorrect(self);

    /* connect module */
    self->driver_board->mcu = self->mcu;
    self->encoder->mcu = self->mcu;
    self->controller->motor = self->stepper_motor;
    self->step_controller.mcu = self->mcu;
    self->flash_manager_param->mcu = self->mcu;
    self->logger->mcu = self->mcu;

    /*** module param settings ***/
    /* Protection */
    self->protection.Init = Protection_Init;
    self->protection.param_version.number.all = (((uint16_t)PROTECTION_VERSION_MAJOR << 8) | ((uint16_t)PROTECTION_VERSION_MINOR));
    self->protection.param_version.release_date = PROTECTION_RELEASE_DATE;
    self->protection.param_en = 1;
    self->protection.param_enable_report = 0;
    // self->protection.param_check_period_s = self->param_task_period_s;
    self->protection.param_err_code_mask = 0xffffffff;
    self->protection.param_warning_code_mask = 0xffffffff;
    self->protection.param_encoder_mutation_coefficient_upper = 0.5;
    self->protection.param_encoder_mutation_coefficient_lower = 0.1;
    self->protection.param_peak_overcurrent_A = 999.0;
    self->protection.param_continuous_overcurrent_A = 2.5;
    self->protection.param_continuous_overcurrent_time_s = 1.0;
    self->protection.param_speed_over_limit_rad_s = 1000 * RPM2RAD;
    self->protection.param_speed_over_limit_time_s = 0.1;
    self->protection.param_pos_over_limit_max_rad = 999;
    self->protection.param_pos_over_limit_min_rad = -999;
    self->protection.param_pos_cmd_mutation_turns = 0.1;
    self->protection.param_pos_tracking_error_maximum_rad = 0.3;
    self->protection.param_pos_tracking_error_time_s = 0.1;
    self->protection.param_power_voltage_min = 20.0;
    self->protection.param_mcu_temp_max = 115.0;

    /* Chopper param */
    self->chopper.Init = Chopper_Init;
    self->chopper.param_chopper_mode = ChopperMode_SlowDecay;
    self->chopper.param_svpwm_mode = SVPWMMode_2phase8vector;
    self->chopper.param_base_pwm = 0.0;
    self->chopper.param_offset_pwm_en = 0;
    self->chopper.param_offset_pwm = 0.02;
    self->chopper.param_hybrid_decay_ratio = 99999999;

    /* StepController param */
    self->step_controller.Init = StepController_Init;
    self->step_controller.param_pulse_count_max = 65000;
    self->step_controller.param_subdivision = 16;
    self->step_controller.param_pulse_trim_en = 0;
    self->step_controller.param_trim_action_period = 10;
    self->step_controller.param_extra_trim_pulse = 10;

    /* S Curve Init */
    // self->scurve.Init = SCurve_Init;
    // self->scurve.param_period_s = 0.02;
    // self->scurve.param_acc_max = 10;
    // self->scurve.param_speed_max = 100;
    // self->scurve.param_jerk = 1000;

    /* CommunicationInterface */
    self->communication_interface.Init = CommunicationInterface_Init;
    self->communication_interface.param_version.number.all = (((uint16_t)CMD_SYSTEM_VERSION_MAJOR << 8) | ((uint16_t)CMD_SYSTEM_VERSION_MINOR));
    self->communication_interface.param_version.release_date = CMD_SYSTEM_RELEASE_DATE;
    self->communication_interface.param_char_cmd_support = TRUE;
    self->communication_interface.param_slave_addr = SlaveAddr_Invalid;
    self->communication_interface.param_receive_buff_addr = UartRxBuff;
    self->communication_interface.period_s = 0.02;
    self->communication_interface.param_data_frame_head_master = 0xff;
    self->communication_interface.param_data_frame_head_slave = 0xee;

    /* system id */
    // self->system_id_RL.param_Ts = self->param_cur_control_period_s;
    float uin_tmp[5] = {0.06, 0.15, 0.13, 0.3, 0.4};
    memcpy(self->system_id_RL.param_uin_series, uin_tmp, sizeof(uin_tmp));
    self->system_id_RL.param_current_stable_err_condition = 0.0005;
    self->system_id_RL.param_current_buff_size = 300;
    self->system_id_RL.param_current_err_size = 20;
    self->system_id_RL.param_prepare_time = 5000;
    self->system_id_RL.param_normal_R_range_min = 0.1;
    self->system_id_RL.param_normal_R_range_max = 100;
    self->system_id_RL.param_normal_L_range_min = 1e-6;
    self->system_id_RL.param_normal_L_range_max = 1000000e-6;

    /* motor phase check */
    self->motor_phase_check.param_run_on_startup = 1;
    self->motor_phase_check.param_motor_resistance_tolerance_standar_percent = 30;

    /* zazen mode */
    self->zazen_mode.param_en = 1;
    self->zazen_mode.param_trigger_time_s = 1.0;
    self->zazen_mode.param_gain.pos_kp = 1.0;
    self->zazen_mode.param_gain.spd_kp = 0.5;
    self->zazen_mode.param_gain.spd_ki = 0.5;
    self->zazen_mode.param_gain.cur_kp = 1.0;
    self->zazen_mode.param_gain.cur_ki = 1.0;

    /* param settings */
    ParamFurtherSetup(self);
}

void DefaultParam_Init_Encder3V3KE_X(StepperMotorController *self)
{
    memset(self, 0, sizeof(StepperMotorController));

    /* Init stepper_motor_controller */
    self->ConfigParam = DefaultParam_Init_Encder3V3KE_X;
    self->Init = StepperMotorController_Init;
    self->driver_board = &driver_board_motor_drv42_v12;
    self->stepper_motor = &stepper_motor_Moons_4234_MS17HD4P4150;
    self->encoder = &encoder_MT6826_15bit;
    self->mcu = &mcu_ch32v303CBT6_v12;
    self->controller = &controller_Ender3V3KE_X;
    // self->controller = &controller_ParallelLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    // self->controller = &controller_FhanLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    self->flash_manager_param = &flash_manager_param_v1_0;
    self->param_firmware_version.number.all = (((uint32_t)FIRMWARE_VERSION_MAJOR << 24) | ((uint32_t)FIRMWARE_VERSION_MINOR << 16) | ((uint32_t)FIRMWARE_VERSION_PATCH << 8) | ((uint32_t)FIRMWARE_VERSION_COMPILED));
    self->param_firmware_version.release_date = FIRMWARE_RELEASE_DATE;
    self->param_boot_key = BOOT_SKIP_KEY;
    // self->flash_manager_encoder_table = &flash_manager_encoder_calibration;
    self->logger = &logger_v1_0;

    self->param_flash_key_write_retries_num = 5;

    self->param_system_startup_delay_ms = 100;

    self->param_pwm_period_s = 3.5e-5;
    self->param_task_period_s = 14e-5;

    self->param_use_default_param = FALSE;
    self->param_singleturn_control_mode = TRUE;

    /** elec angle offset */
    self->param_elec_angle_calibration_standar_deg = 15.0F;

    self->param_elec_offset = 152.32; // default

    self->param_phase_order_invert = 1;

    /** rotor block dec */
    self->param_emergency_pin_mode = Emergency_Pin_Mode_Stall;
    self->param_stall_mode = StallMode_Pos;
    self->param_stall_cur_A = 0.7;
    self->param_stall_pos_err_rad = 0.015;

    /* dir of elec offset calibration and encoder_calibtate_official */
    self->param_calibration_dir = -1;

    /* param of encoder calibration and zero offset calibration */
    self->param_encoder_cal_count_max = 200;
    self->param_encoder_read_count = 10;
    self->param_delay_ms_per_step = 10;
    self->param_delay_ms_per_read = 1;
    self->param_ud_cal_set = 0.15;
    self->param_motion_dir = 1;

    /* encoder calibrate official */
    self->param_encoder_calibtate_official_cal_count_max = 200 * 32;
    self->param_encoder_calibtate_official_ud_cal_set = 0.15;
    self->param_encoder_calibration_round_count = 40;

    /* config module */
    self->stepper_motor->ConfigParam(self->stepper_motor);
    self->encoder->ConfigParam(self->encoder);
    self->mcu->ConfigParam(self->mcu);
    self->controller->ConfigParam(self->controller);
    self->driver_board->ConfigParam(self->driver_board);
    self->flash_manager_param->ConfigParam(self->flash_manager_param);
    // self->flash_manager_encoder_table->ConfigParam(self->flash_manager_encoder_table);
    self->logger->ConfigParam(self->logger);
    PeriodCorrect(self);

    /* connect module */
    self->driver_board->mcu = self->mcu;
    self->encoder->mcu = self->mcu;
    self->controller->motor = self->stepper_motor;
    self->step_controller.mcu = self->mcu;
    self->flash_manager_param->mcu = self->mcu;
    self->logger->mcu = self->mcu;

    /*** module param settings ***/
    /* Protection */
    self->protection.Init = Protection_Init;
    self->protection.param_version.number.all = (((uint16_t)PROTECTION_VERSION_MAJOR << 8) | ((uint16_t)PROTECTION_VERSION_MINOR));
    self->protection.param_version.release_date = PROTECTION_RELEASE_DATE;
    self->protection.param_en = 0;
    self->protection.param_enable_report = 0;
    // self->protection.param_check_period_s = self->param_task_period_s;
    self->protection.param_err_code_mask = 0xffffffff;
    self->protection.param_warning_code_mask = 0xffffffff;
    self->protection.param_encoder_mutation_coefficient_upper = 0.5;
    self->protection.param_encoder_mutation_coefficient_lower = 0.1;
    self->protection.param_peak_overcurrent_A = 999.0;
    self->protection.param_continuous_overcurrent_A = 4.0;
    self->protection.param_continuous_overcurrent_time_s = 2.0;
    self->protection.param_speed_over_limit_rad_s = 3000 * RPM2RAD;
    self->protection.param_speed_over_limit_time_s = 0.1;
    self->protection.param_pos_over_limit_max_rad = 999;
    self->protection.param_pos_over_limit_min_rad = -999;
    self->protection.param_pos_cmd_mutation_turns = 0.1;
    self->protection.param_pos_tracking_error_maximum_rad = 0.3;
    self->protection.param_pos_tracking_error_time_s = 0.1;
    self->protection.param_power_voltage_min = 20.0;
    self->protection.param_mcu_temp_max = 115.0;

    /* Chopper param */
    self->chopper.Init = Chopper_Init;
    self->chopper.param_chopper_mode = ChopperMode_SlowDecay;
    self->chopper.param_svpwm_mode = SVPWMMode_2phase8vector;
    self->chopper.param_base_pwm = 0.0;
    self->chopper.param_offset_pwm_en = 0;
    self->chopper.param_offset_pwm = 0.02;
    self->chopper.param_hybrid_decay_ratio = 99999999;

    /* StepController param */
    self->step_controller.Init = StepController_Init;
    self->step_controller.param_pulse_count_max = 65000;
    self->step_controller.param_subdivision = 16;
    self->step_controller.param_pulse_trim_en = 0;
    self->step_controller.param_trim_action_period = 10;
    self->step_controller.param_extra_trim_pulse = 10;

    /* S Curve Init */
    // self->scurve.Init = SCurve_Init;
    // self->scurve.param_period_s = 0.02;
    // self->scurve.param_acc_max = 10;
    // self->scurve.param_speed_max = 100;
    // self->scurve.param_jerk = 1000;

    /* CommunicationInterface */
    self->communication_interface.Init = CommunicationInterface_Init;
    self->communication_interface.param_version.number.all = (((uint16_t)CMD_SYSTEM_VERSION_MAJOR << 8) | ((uint16_t)CMD_SYSTEM_VERSION_MINOR));
    self->communication_interface.param_version.release_date = CMD_SYSTEM_RELEASE_DATE;
    self->communication_interface.param_char_cmd_support = TRUE;
    self->communication_interface.param_slave_addr = SlaveAddr_Invalid;
    self->communication_interface.param_receive_buff_addr = UartRxBuff;
    self->communication_interface.period_s = 0.02;
    self->communication_interface.param_data_frame_head_master = 0xff;
    self->communication_interface.param_data_frame_head_slave = 0xee;

    /* system id */
    // self->system_id_RL.param_Ts = self->param_cur_control_period_s;
    float uin_tmp[5] = {0.06, 0.15, 0.13, 0.3, 0.4};
    memcpy(self->system_id_RL.param_uin_series, uin_tmp, sizeof(uin_tmp));
    self->system_id_RL.param_current_stable_err_condition = 0.0005;
    self->system_id_RL.param_current_buff_size = 300;
    self->system_id_RL.param_current_err_size = 20;
    self->system_id_RL.param_prepare_time = 5000;
    self->system_id_RL.param_normal_R_range_min = 0.1;
    self->system_id_RL.param_normal_R_range_max = 100;
    self->system_id_RL.param_normal_L_range_min = 1e-6;
    self->system_id_RL.param_normal_L_range_max = 1000000e-6;

    /* motor phase check */
    self->motor_phase_check.param_run_on_startup = 1;
    self->motor_phase_check.param_motor_resistance_tolerance_standar_percent = 30;

    /* zazen mode */
    self->zazen_mode.param_en = 0;
    self->zazen_mode.param_trigger_time_s = 1.0;
    self->zazen_mode.param_gain.pos_kp = 1.0;
    self->zazen_mode.param_gain.spd_kp = 0.5;
    self->zazen_mode.param_gain.spd_ki = 0.5;
    self->zazen_mode.param_gain.cur_kp = 0.5;
    self->zazen_mode.param_gain.cur_ki = 0.5;

    /* param settings */
    ParamFurtherSetup(self);
}

void DefaultParam_Init_Encder3V3KE_Y(StepperMotorController *self)
{
    memset(self, 0, sizeof(StepperMotorController));

    /* Init stepper_motor_controller */
    self->ConfigParam = DefaultParam_Init_Encder3V3KE_Y;
    self->Init = StepperMotorController_Init;
    self->driver_board = &driver_board_motor_drv42_v12;
    self->stepper_motor = &stepper_motor_Moons_4234_MS17HD4P4150;
    self->encoder = &encoder_MT6826_15bit;
    self->mcu = &mcu_ch32v303CBT6_v12;
    self->controller = &controller_Ender3V3KE_Y;
    // self->controller = &controller_ParallelLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    // self->controller = &controller_FhanLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    self->flash_manager_param = &flash_manager_param_v1_0;
    self->param_firmware_version.number.all = (((uint32_t)FIRMWARE_VERSION_MAJOR << 24) | ((uint32_t)FIRMWARE_VERSION_MINOR << 16) | ((uint32_t)FIRMWARE_VERSION_PATCH << 8) | ((uint32_t)FIRMWARE_VERSION_COMPILED));
    self->param_firmware_version.release_date = FIRMWARE_RELEASE_DATE;
    self->param_boot_key = BOOT_SKIP_KEY;
    // self->flash_manager_encoder_table = &flash_manager_encoder_calibration;
    self->logger = &logger_v1_0;

    self->param_flash_key_write_retries_num = 5;

    self->param_system_startup_delay_ms = 100;

    self->param_pwm_period_s = 3.5e-5;
    self->param_task_period_s = 14e-5;

    self->param_use_default_param = FALSE;
    self->param_singleturn_control_mode = TRUE;

    /** elec angle offset */
    self->param_elec_angle_calibration_standar_deg = 15.0F;

    self->param_elec_offset = 576.38; // default

    self->param_phase_order_invert = 1;

    /** rotor block dec */
    self->param_emergency_pin_mode = Emergency_Pin_Mode_Stall;
    self->param_stall_mode = StallMode_Pos;
    self->param_stall_cur_A = 0.7;
    self->param_stall_pos_err_rad = 0.015;

    /* dir of elec offset calibration and encoder_calibtate_official */
    self->param_calibration_dir = -1;

    /* param of encoder calibration and zero offset calibration */
    self->param_encoder_cal_count_max = 200;
    self->param_encoder_read_count = 10;
    self->param_delay_ms_per_step = 10;
    self->param_delay_ms_per_read = 1;
    self->param_ud_cal_set = 0.15;
    self->param_motion_dir = 1;

    /* encoder calibrate official */
    self->param_encoder_calibtate_official_cal_count_max = 200 * 32;
    self->param_encoder_calibtate_official_ud_cal_set = 0.15;
    self->param_encoder_calibration_round_count = 40;

    /* config module */
    self->stepper_motor->ConfigParam(self->stepper_motor);
    self->encoder->ConfigParam(self->encoder);
    self->mcu->ConfigParam(self->mcu);
    self->controller->ConfigParam(self->controller);
    self->driver_board->ConfigParam(self->driver_board);
    self->flash_manager_param->ConfigParam(self->flash_manager_param);
    // self->flash_manager_encoder_table->ConfigParam(self->flash_manager_encoder_table);
    self->logger->ConfigParam(self->logger);
    PeriodCorrect(self);

    /* connect module */
    self->driver_board->mcu = self->mcu;
    self->encoder->mcu = self->mcu;
    self->controller->motor = self->stepper_motor;
    self->step_controller.mcu = self->mcu;
    self->flash_manager_param->mcu = self->mcu;
    self->logger->mcu = self->mcu;

    /*** module param settings ***/
    /* Protection */
    self->protection.Init = Protection_Init;
    self->protection.param_version.number.all = (((uint16_t)PROTECTION_VERSION_MAJOR << 8) | ((uint16_t)PROTECTION_VERSION_MINOR));
    self->protection.param_version.release_date = PROTECTION_RELEASE_DATE;
    self->protection.param_en = 0;
    self->protection.param_enable_report = 0;
    // self->protection.param_check_period_s = self->param_task_period_s;
    self->protection.param_err_code_mask = 0xffffffff;
    self->protection.param_warning_code_mask = 0xffffffff;
    self->protection.param_encoder_mutation_coefficient_upper = 0.5;
    self->protection.param_encoder_mutation_coefficient_lower = 0.1;
    self->protection.param_peak_overcurrent_A = 999.0;
    self->protection.param_continuous_overcurrent_A = 4.0;
    self->protection.param_continuous_overcurrent_time_s = 2.0;
    self->protection.param_speed_over_limit_rad_s = 3000 * RPM2RAD;
    self->protection.param_speed_over_limit_time_s = 0.1;
    self->protection.param_pos_over_limit_max_rad = 999;
    self->protection.param_pos_over_limit_min_rad = -999;
    self->protection.param_pos_cmd_mutation_turns = 0.1;
    self->protection.param_pos_tracking_error_maximum_rad = 0.3;
    self->protection.param_pos_tracking_error_time_s = 0.1;
    self->protection.param_power_voltage_min = 20.0;
    self->protection.param_mcu_temp_max = 115.0;

    /* Chopper param */
    self->chopper.Init = Chopper_Init;
    self->chopper.param_chopper_mode = ChopperMode_SlowDecay;
    self->chopper.param_svpwm_mode = SVPWMMode_2phase8vector;
    self->chopper.param_base_pwm = 0.0;
    self->chopper.param_offset_pwm_en = 0;
    self->chopper.param_offset_pwm = 0.02;
    self->chopper.param_hybrid_decay_ratio = 99999999;

    /* StepController param */
    self->step_controller.Init = StepController_Init;
    self->step_controller.param_pulse_count_max = 65000;
    self->step_controller.param_subdivision = 16;
    self->step_controller.param_pulse_trim_en = 0;
    self->step_controller.param_trim_action_period = 10;
    self->step_controller.param_extra_trim_pulse = 10;

    /* S Curve Init */
    // self->scurve.Init = SCurve_Init;
    // self->scurve.param_period_s = 0.02;
    // self->scurve.param_acc_max = 10;
    // self->scurve.param_speed_max = 100;
    // self->scurve.param_jerk = 1000;

    /* CommunicationInterface */
    self->communication_interface.Init = CommunicationInterface_Init;
    self->communication_interface.param_version.number.all = (((uint16_t)CMD_SYSTEM_VERSION_MAJOR << 8) | ((uint16_t)CMD_SYSTEM_VERSION_MINOR));
    self->communication_interface.param_version.release_date = CMD_SYSTEM_RELEASE_DATE;
    self->communication_interface.param_char_cmd_support = TRUE;
    self->communication_interface.param_slave_addr = SlaveAddr_Invalid;
    self->communication_interface.param_receive_buff_addr = UartRxBuff;
    self->communication_interface.period_s = 0.02;
    self->communication_interface.param_data_frame_head_master = 0xff;
    self->communication_interface.param_data_frame_head_slave = 0xee;

    /* system id */
    // self->system_id_RL.param_Ts = self->param_cur_control_period_s;
    float uin_tmp[5] = {0.06, 0.15, 0.13, 0.3, 0.4};
    memcpy(self->system_id_RL.param_uin_series, uin_tmp, sizeof(uin_tmp));
    self->system_id_RL.param_current_stable_err_condition = 0.0005;
    self->system_id_RL.param_current_buff_size = 300;
    self->system_id_RL.param_current_err_size = 20;
    self->system_id_RL.param_prepare_time = 5000;
    self->system_id_RL.param_normal_R_range_min = 0.1;
    self->system_id_RL.param_normal_R_range_max = 100;
    self->system_id_RL.param_normal_L_range_min = 1e-6;
    self->system_id_RL.param_normal_L_range_max = 1000000e-6;

    /* motor phase check */
    self->motor_phase_check.param_run_on_startup = 1;
    self->motor_phase_check.param_motor_resistance_tolerance_standar_percent = 30;

    /* zazen mode */
    self->zazen_mode.param_en = 0;
    self->zazen_mode.param_trigger_time_s = 1.0;
    self->zazen_mode.param_gain.pos_kp = 1.0;
    self->zazen_mode.param_gain.spd_kp = 0.5;
    self->zazen_mode.param_gain.spd_ki = 0.5;
    self->zazen_mode.param_gain.cur_kp = 0.5;
    self->zazen_mode.param_gain.cur_ki = 0.5;

    /* param settings */
    ParamFurtherSetup(self);
}

void DefaultParam_Init_Encder3V3KE_Z(StepperMotorController *self)
{
    memset(self, 0, sizeof(StepperMotorController));

    /* Init stepper_motor_controller */
    self->ConfigParam = DefaultParam_Init_Encder3V3KE_Z;
    self->Init = StepperMotorController_Init;
    self->driver_board = &driver_board_motor_drv42_v12;
    self->stepper_motor = &stepper_motor_default; //&stepper_motor_Moons_4248_MS17HDB3P4250;
    self->encoder = &encoder_MT6826_15bit;
    self->mcu = &mcu_ch32v303CBT6_v12;
    self->controller = &controller_PF019Pro_Z;
    // self->controller = &controller_ParallelLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    // self->controller = &controller_FhanLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    self->flash_manager_param = &flash_manager_param_v1_0;
    self->param_firmware_version.number.all = (((uint32_t)FIRMWARE_VERSION_MAJOR << 24) | ((uint32_t)FIRMWARE_VERSION_MINOR << 16) | ((uint32_t)FIRMWARE_VERSION_PATCH << 8) | ((uint32_t)FIRMWARE_VERSION_COMPILED));
    self->param_firmware_version.release_date = FIRMWARE_RELEASE_DATE;
    self->param_boot_key = BOOT_SKIP_KEY;
    // self->flash_manager_encoder_table = &flash_manager_encoder_calibration;
    self->logger = &logger_v1_0;

    self->param_flash_key_write_retries_num = 5;

    self->param_system_startup_delay_ms = 100;

    self->param_pwm_period_s = 3.5e-5;
    self->param_task_period_s = 14e-5;

    self->param_use_default_param = FALSE;
    self->param_singleturn_control_mode = TRUE;

    /** elec angle offset */
    self->param_elec_angle_calibration_standar_deg = 15.0F;

    self->param_elec_offset = 152.32; // default

    self->param_phase_order_invert = 1;

    /** rotor block dec */
    self->param_emergency_pin_mode = Emergency_Pin_Mode_Stall;
    self->param_stall_mode = StallMode_Pos;
    self->param_stall_cur_A = 0.7;
    self->param_stall_pos_err_rad = 0.015;

    /* dir of elec offset calibration and encoder_calibtate_official */
    self->param_calibration_dir = -1;

    /* param of encoder calibration and zero offset calibration */
    self->param_encoder_cal_count_max = 200;
    self->param_encoder_read_count = 10;
    self->param_delay_ms_per_step = 10;
    self->param_delay_ms_per_read = 1;
    self->param_ud_cal_set = 0.15;
    self->param_motion_dir = 1;

    /* encoder calibrate official */
    self->param_encoder_calibtate_official_cal_count_max = 200 * 32;
    self->param_encoder_calibtate_official_ud_cal_set = 0.15;
    self->param_encoder_calibration_round_count = 40;

    /* config module */
    self->stepper_motor->ConfigParam(self->stepper_motor);
    self->encoder->ConfigParam(self->encoder);
    self->mcu->ConfigParam(self->mcu);
    self->controller->ConfigParam(self->controller);
    self->driver_board->ConfigParam(self->driver_board);
    self->flash_manager_param->ConfigParam(self->flash_manager_param);
    // self->flash_manager_encoder_table->ConfigParam(self->flash_manager_encoder_table);
    self->logger->ConfigParam(self->logger);
    PeriodCorrect(self);

    /* connect module */
    self->driver_board->mcu = self->mcu;
    self->encoder->mcu = self->mcu;
    self->controller->motor = self->stepper_motor;
    self->step_controller.mcu = self->mcu;
    self->flash_manager_param->mcu = self->mcu;
    self->logger->mcu = self->mcu;

    /*** module param settings ***/
    /* Protection */
    self->protection.Init = Protection_Init;
    self->protection.param_version.number.all = (((uint16_t)PROTECTION_VERSION_MAJOR << 8) | ((uint16_t)PROTECTION_VERSION_MINOR));
    self->protection.param_version.release_date = PROTECTION_RELEASE_DATE;
    self->protection.param_en = 0;
    self->protection.param_enable_report = 0;
    // self->protection.param_check_period_s = self->param_task_period_s;
    self->protection.param_err_code_mask = 0xffffffff;
    self->protection.param_warning_code_mask = 0xffffffff;
    self->protection.param_encoder_mutation_coefficient_upper = 0.5;
    self->protection.param_encoder_mutation_coefficient_lower = 0.1;
    self->protection.param_peak_overcurrent_A = 999.0;
    self->protection.param_continuous_overcurrent_A = 4.0;
    self->protection.param_continuous_overcurrent_time_s = 2.0;
    self->protection.param_speed_over_limit_rad_s = 3000 * RPM2RAD;
    self->protection.param_speed_over_limit_time_s = 0.1;
    self->protection.param_pos_over_limit_max_rad = 999;
    self->protection.param_pos_over_limit_min_rad = -999;
    self->protection.param_pos_cmd_mutation_turns = 0.1;
    self->protection.param_pos_tracking_error_maximum_rad = 0.3;
    self->protection.param_pos_tracking_error_time_s = 0.1;
    self->protection.param_power_voltage_min = 20.0;
    self->protection.param_mcu_temp_max = 115.0;

    /* Chopper param */
    self->chopper.Init = Chopper_Init;
    self->chopper.param_chopper_mode = ChopperMode_SlowDecay;
    self->chopper.param_svpwm_mode = SVPWMMode_2phase8vector;
    self->chopper.param_base_pwm = 0.0;
    self->chopper.param_offset_pwm_en = 0;
    self->chopper.param_offset_pwm = 0.02;
    self->chopper.param_hybrid_decay_ratio = 99999999;

    /* StepController param */
    self->step_controller.Init = StepController_Init;
    self->step_controller.param_pulse_count_max = 65000;
    self->step_controller.param_subdivision = 16;
    self->step_controller.param_pulse_trim_en = 0;
    self->step_controller.param_trim_action_period = 10;
    self->step_controller.param_extra_trim_pulse = 10;

    /* S Curve Init */
    // self->scurve.Init = SCurve_Init;
    // self->scurve.param_period_s = 0.02;
    // self->scurve.param_acc_max = 10;
    // self->scurve.param_speed_max = 100;
    // self->scurve.param_jerk = 1000;

    /* CommunicationInterface */
    self->communication_interface.Init = CommunicationInterface_Init;
    self->communication_interface.param_version.number.all = (((uint16_t)CMD_SYSTEM_VERSION_MAJOR << 8) | ((uint16_t)CMD_SYSTEM_VERSION_MINOR));
    self->communication_interface.param_version.release_date = CMD_SYSTEM_RELEASE_DATE;
    self->communication_interface.param_char_cmd_support = TRUE;
    self->communication_interface.param_slave_addr = SlaveAddr_Invalid;
    self->communication_interface.param_receive_buff_addr = UartRxBuff;
    self->communication_interface.period_s = 0.02;
    self->communication_interface.param_data_frame_head_master = 0xff;
    self->communication_interface.param_data_frame_head_slave = 0xee;

    /* system id */
    // self->system_id_RL.param_Ts = self->param_cur_control_period_s;
    float uin_tmp[5] = {0.06, 0.15, 0.13, 0.3, 0.4};
    memcpy(self->system_id_RL.param_uin_series, uin_tmp, sizeof(uin_tmp));
    self->system_id_RL.param_current_stable_err_condition = 0.0005;
    self->system_id_RL.param_current_buff_size = 300;
    self->system_id_RL.param_current_err_size = 20;
    self->system_id_RL.param_prepare_time = 5000;
    self->system_id_RL.param_normal_R_range_min = 0.1;
    self->system_id_RL.param_normal_R_range_max = 100;
    self->system_id_RL.param_normal_L_range_min = 1e-6;
    self->system_id_RL.param_normal_L_range_max = 1000000e-6;

    /* motor phase check */
    self->motor_phase_check.param_run_on_startup = 1;
    self->motor_phase_check.param_motor_resistance_tolerance_standar_percent = 30;

    /* zazen mode */
    self->zazen_mode.param_en = 0;
    self->zazen_mode.param_trigger_time_s = 1.0;
    self->zazen_mode.param_gain.pos_kp = 1.0;
    self->zazen_mode.param_gain.spd_kp = 0.5;
    self->zazen_mode.param_gain.spd_ki = 0.5;
    self->zazen_mode.param_gain.cur_kp = 0.5;
    self->zazen_mode.param_gain.cur_ki = 0.5;

    /* param settings */
    ParamFurtherSetup(self);
}

void DefaultParam_Init_Encder3V3KE_E(StepperMotorController *self)
{
    memset(self, 0, sizeof(StepperMotorController));

    /* Init stepper_motor_controller */
    self->ConfigParam = DefaultParam_Init_Encder3V3KE_E;
    self->Init = StepperMotorController_Init;
    self->driver_board = &driver_board_motor_drv42_v12;
    self->stepper_motor = &stepper_motor_default; //&stepper_motor_Moons_4248_MS17HDB3P4250;
    self->encoder = &encoder_MT6826_15bit;
    self->mcu = &mcu_ch32v303CBT6_v12;
    self->controller = &controller_PF019Pro_Z;
    // self->controller = &controller_ParallelLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    // self->controller = &controller_FhanLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    self->flash_manager_param = &flash_manager_param_v1_0;
    self->param_firmware_version.number.all = (((uint32_t)FIRMWARE_VERSION_MAJOR << 24) | ((uint32_t)FIRMWARE_VERSION_MINOR << 16) | ((uint32_t)FIRMWARE_VERSION_PATCH << 8) | ((uint32_t)FIRMWARE_VERSION_COMPILED));
    self->param_firmware_version.release_date = FIRMWARE_RELEASE_DATE;
    self->param_boot_key = BOOT_SKIP_KEY;
    // self->flash_manager_encoder_table = &flash_manager_encoder_calibration;
    self->logger = &logger_v1_0;

    self->param_flash_key_write_retries_num = 5;

    self->param_system_startup_delay_ms = 100;

    self->param_pwm_period_s = 3.5e-5;
    self->param_task_period_s = 14e-5;

    self->param_use_default_param = FALSE;
    self->param_singleturn_control_mode = TRUE;

    /** elec angle offset */
    self->param_elec_angle_calibration_standar_deg = 15.0F;

    self->param_elec_offset = 152.32; // default

    self->param_phase_order_invert = 1;

    /** rotor block dec */
    self->param_emergency_pin_mode = Emergency_Pin_Mode_Stall;
    self->param_stall_mode = StallMode_Pos;
    self->param_stall_cur_A = 0.7;
    self->param_stall_pos_err_rad = 0.015;

    /* dir of elec offset calibration and encoder_calibtate_official */
    self->param_calibration_dir = -1;

    /* param of encoder calibration and zero offset calibration */
    self->param_encoder_cal_count_max = 200;
    self->param_encoder_read_count = 10;
    self->param_delay_ms_per_step = 10;
    self->param_delay_ms_per_read = 1;
    self->param_ud_cal_set = 0.15;
    self->param_motion_dir = 1;

    /* encoder calibrate official */
    self->param_encoder_calibtate_official_cal_count_max = 200 * 32;
    self->param_encoder_calibtate_official_ud_cal_set = 0.15;
    self->param_encoder_calibration_round_count = 40;

    /* config module */
    self->stepper_motor->ConfigParam(self->stepper_motor);
    self->encoder->ConfigParam(self->encoder);
    self->mcu->ConfigParam(self->mcu);
    self->controller->ConfigParam(self->controller);
    self->driver_board->ConfigParam(self->driver_board);
    self->flash_manager_param->ConfigParam(self->flash_manager_param);
    // self->flash_manager_encoder_table->ConfigParam(self->flash_manager_encoder_table);
    self->logger->ConfigParam(self->logger);
    PeriodCorrect(self);

    /* connect module */
    self->driver_board->mcu = self->mcu;
    self->encoder->mcu = self->mcu;
    self->controller->motor = self->stepper_motor;
    self->step_controller.mcu = self->mcu;
    self->flash_manager_param->mcu = self->mcu;
    self->logger->mcu = self->mcu;

    /*** module param settings ***/
    /* Protection */
    self->protection.Init = Protection_Init;
    self->protection.param_version.number.all = (((uint16_t)PROTECTION_VERSION_MAJOR << 8) | ((uint16_t)PROTECTION_VERSION_MINOR));
    self->protection.param_version.release_date = PROTECTION_RELEASE_DATE;
    self->protection.param_en = 0;
    self->protection.param_enable_report = 0;
    // self->protection.param_check_period_s = self->param_task_period_s;
    self->protection.param_err_code_mask = 0xffffffff;
    self->protection.param_warning_code_mask = 0xffffffff;
    self->protection.param_encoder_mutation_coefficient_upper = 0.5;
    self->protection.param_encoder_mutation_coefficient_lower = 0.1;
    self->protection.param_peak_overcurrent_A = 999.0;
    self->protection.param_continuous_overcurrent_A = 4.0;
    self->protection.param_continuous_overcurrent_time_s = 2.0;
    self->protection.param_speed_over_limit_rad_s = 3000 * RPM2RAD;
    self->protection.param_speed_over_limit_time_s = 0.1;
    self->protection.param_pos_over_limit_max_rad = 999;
    self->protection.param_pos_over_limit_min_rad = -999;
    self->protection.param_pos_cmd_mutation_turns = 0.1;
    self->protection.param_pos_tracking_error_maximum_rad = 0.3;
    self->protection.param_pos_tracking_error_time_s = 0.1;
    self->protection.param_power_voltage_min = 20.0;
    self->protection.param_mcu_temp_max = 115.0;

    /* Chopper param */
    self->chopper.Init = Chopper_Init;
    self->chopper.param_chopper_mode = ChopperMode_SlowDecay;
    self->chopper.param_svpwm_mode = SVPWMMode_2phase8vector;
    self->chopper.param_base_pwm = 0.0;
    self->chopper.param_offset_pwm_en = 0;
    self->chopper.param_offset_pwm = 0.02;
    self->chopper.param_hybrid_decay_ratio = 99999999;

    /* StepController param */
    self->step_controller.Init = StepController_Init;
    self->step_controller.param_pulse_count_max = 65000;
    self->step_controller.param_subdivision = 16;
    self->step_controller.param_pulse_trim_en = 0;
    self->step_controller.param_trim_action_period = 10;
    self->step_controller.param_extra_trim_pulse = 10;

    /* S Curve Init */
    // self->scurve.Init = SCurve_Init;
    // self->scurve.param_period_s = 0.02;
    // self->scurve.param_acc_max = 10;
    // self->scurve.param_speed_max = 100;
    // self->scurve.param_jerk = 1000;

    /* CommunicationInterface */
    self->communication_interface.Init = CommunicationInterface_Init;
    self->communication_interface.param_version.number.all = (((uint16_t)CMD_SYSTEM_VERSION_MAJOR << 8) | ((uint16_t)CMD_SYSTEM_VERSION_MINOR));
    self->communication_interface.param_version.release_date = CMD_SYSTEM_RELEASE_DATE;
    self->communication_interface.param_char_cmd_support = TRUE;
    self->communication_interface.param_slave_addr = SlaveAddr_Invalid;
    self->communication_interface.param_receive_buff_addr = UartRxBuff;
    self->communication_interface.period_s = 0.02;
    self->communication_interface.param_data_frame_head_master = 0xff;
    self->communication_interface.param_data_frame_head_slave = 0xee;

    /* system id */
    // self->system_id_RL.param_Ts = self->param_cur_control_period_s;
    float uin_tmp[5] = {0.06, 0.15, 0.13, 0.3, 0.4};
    memcpy(self->system_id_RL.param_uin_series, uin_tmp, sizeof(uin_tmp));
    self->system_id_RL.param_current_stable_err_condition = 0.0005;
    self->system_id_RL.param_current_buff_size = 300;
    self->system_id_RL.param_current_err_size = 20;
    self->system_id_RL.param_prepare_time = 5000;
    self->system_id_RL.param_normal_R_range_min = 0.1;
    self->system_id_RL.param_normal_R_range_max = 100;
    self->system_id_RL.param_normal_L_range_min = 1e-6;
    self->system_id_RL.param_normal_L_range_max = 1000000e-6;

    /* motor phase check */
    self->motor_phase_check.param_run_on_startup = 1;
    self->motor_phase_check.param_motor_resistance_tolerance_standar_percent = 30;

    /* zazen mode */
    self->zazen_mode.param_en = 0;
    self->zazen_mode.param_trigger_time_s = 1.0;
    self->zazen_mode.param_gain.pos_kp = 1.0;
    self->zazen_mode.param_gain.spd_kp = 0.5;
    self->zazen_mode.param_gain.spd_ki = 0.5;
    self->zazen_mode.param_gain.cur_kp = 0.5;
    self->zazen_mode.param_gain.cur_ki = 0.5;

    /* param settings */
    ParamFurtherSetup(self);
}

void DefaultParam_Init_K1Max_XY(StepperMotorController *self)
{
    memset(self, 0, sizeof(StepperMotorController));

    /* Init stepper_motor_controller */
    self->ConfigParam = DefaultParam_Init_K1Max_XY;
    self->Init = StepperMotorController_Init;
    self->driver_board = &driver_board_motor_drv42_v12;
    self->stepper_motor = &stepper_motor_Moons_4248_MS17HDB3P4250;
    self->encoder = &encoder_MT6826_15bit;
    self->mcu = &mcu_ch32v303CBT6_v12;
    self->controller = &controller_K1Max_XY;
    // self->controller = &controller_ParallelLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    // self->controller = &controller_FhanLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    self->flash_manager_param = &flash_manager_param_v1_0;
    self->param_firmware_version.number.all = (((uint32_t)FIRMWARE_VERSION_MAJOR << 24) | ((uint32_t)FIRMWARE_VERSION_MINOR << 16) | ((uint32_t)FIRMWARE_VERSION_PATCH << 8) | ((uint32_t)FIRMWARE_VERSION_COMPILED));
    self->param_firmware_version.release_date = FIRMWARE_RELEASE_DATE;
    self->param_boot_key = BOOT_SKIP_KEY;
    // self->flash_manager_encoder_table = &flash_manager_encoder_calibration;
    self->logger = &logger_v1_0;

    self->param_flash_key_write_retries_num = 5;

    self->param_system_startup_delay_ms = 100;

    self->param_pwm_period_s = 3.5e-5;
    self->param_task_period_s = 14e-5;

    self->param_use_default_param = FALSE;
    self->param_singleturn_control_mode = TRUE;

    /** elec angle offset */
    self->param_elec_angle_calibration_standar_deg = 15.0F;
    // self->param_elec_offset = 654.80;//PF008a-左
    // self->param_elec_offset = 1252.18;//PF008a-右

    self->param_elec_offset = 401.3; // default

    self->param_phase_order_invert = 1;

    /** rotor block dec */
    self->param_emergency_pin_mode = Emergency_Pin_Mode_Stall;
    self->param_stall_mode = StallMode_Pos;
    self->param_stall_cur_A = 0.7;
    self->param_stall_pos_err_rad = 0.015;

    /* dir of elec offset calibration and encoder_calibtate_official */
    self->param_calibration_dir = -1;

    /* param of encoder calibration and zero offset calibration */
    self->param_encoder_cal_count_max = 200;
    self->param_encoder_read_count = 10;
    self->param_delay_ms_per_step = 10;
    self->param_delay_ms_per_read = 1;
    self->param_ud_cal_set = 0.15;
    self->param_motion_dir = 1;

    /* encoder calibrate official */
    self->param_encoder_calibtate_official_cal_count_max = 200 * 32;
    self->param_encoder_calibtate_official_ud_cal_set = 0.15;
    self->param_encoder_calibration_round_count = 40;

    /* config module */
    self->stepper_motor->ConfigParam(self->stepper_motor);
    self->encoder->ConfigParam(self->encoder);
    self->mcu->ConfigParam(self->mcu);
    self->controller->ConfigParam(self->controller);
    self->driver_board->ConfigParam(self->driver_board);
    self->flash_manager_param->ConfigParam(self->flash_manager_param);
    // self->flash_manager_encoder_table->ConfigParam(self->flash_manager_encoder_table);
    self->logger->ConfigParam(self->logger);
    PeriodCorrect(self);

    /* connect module */
    self->driver_board->mcu = self->mcu;
    self->encoder->mcu = self->mcu;
    self->controller->motor = self->stepper_motor;
    self->step_controller.mcu = self->mcu;
    self->flash_manager_param->mcu = self->mcu;
    self->logger->mcu = self->mcu;

    /*** module param settings ***/
    /* Protection */
    self->protection.Init = Protection_Init;
    self->protection.param_version.number.all = (((uint16_t)PROTECTION_VERSION_MAJOR << 8) | ((uint16_t)PROTECTION_VERSION_MINOR));
    self->protection.param_version.release_date = PROTECTION_RELEASE_DATE;
    self->protection.param_en = 0;
    self->protection.param_enable_report = 0;
    // self->protection.param_check_period_s = self->param_task_period_s;
    self->protection.param_err_code_mask = 0xffffffff;
    self->protection.param_warning_code_mask = 0xffffffff;
    self->protection.param_encoder_mutation_coefficient_upper = 0.5;
    self->protection.param_encoder_mutation_coefficient_lower = 0.1;
    self->protection.param_peak_overcurrent_A = 999.0;
    self->protection.param_continuous_overcurrent_A = 4.0;
    self->protection.param_continuous_overcurrent_time_s = 2.0;
    self->protection.param_speed_over_limit_rad_s = 3000 * RPM2RAD;
    self->protection.param_speed_over_limit_time_s = 0.1;
    self->protection.param_pos_over_limit_max_rad = 999;
    self->protection.param_pos_over_limit_min_rad = -999;
    self->protection.param_pos_cmd_mutation_turns = 0.1;
    self->protection.param_pos_tracking_error_maximum_rad = 0.3;
    self->protection.param_pos_tracking_error_time_s = 0.1;
    self->protection.param_power_voltage_min = 20.0;
    self->protection.param_mcu_temp_max = 115.0;

    /* Chopper param */
    self->chopper.Init = Chopper_Init;
    self->chopper.param_chopper_mode = ChopperMode_SlowDecay;
    self->chopper.param_svpwm_mode = SVPWMMode_2phase8vector;
    self->chopper.param_base_pwm = 0.0;
    self->chopper.param_offset_pwm_en = 0;
    self->chopper.param_offset_pwm = 0.02;
    self->chopper.param_hybrid_decay_ratio = 99999999;

    /* StepController param */
    self->step_controller.Init = StepController_Init;
    self->step_controller.param_pulse_count_max = 65000;
    self->step_controller.param_subdivision = 16;
    self->step_controller.param_pulse_trim_en = 0;
    self->step_controller.param_trim_action_period = 10;
    self->step_controller.param_extra_trim_pulse = 10;

    /* S Curve Init */
    // self->scurve.Init = SCurve_Init;
    // self->scurve.param_period_s = 0.02;
    // self->scurve.param_acc_max = 10;
    // self->scurve.param_speed_max = 100;
    // self->scurve.param_jerk = 1000;

    /* CommunicationInterface */
    self->communication_interface.Init = CommunicationInterface_Init;
    self->communication_interface.param_version.number.all = (((uint16_t)CMD_SYSTEM_VERSION_MAJOR << 8) | ((uint16_t)CMD_SYSTEM_VERSION_MINOR));
    self->communication_interface.param_version.release_date = CMD_SYSTEM_RELEASE_DATE;
    self->communication_interface.param_char_cmd_support = TRUE;
    self->communication_interface.param_slave_addr = SlaveAddr_Invalid;
    self->communication_interface.param_receive_buff_addr = UartRxBuff;
    self->communication_interface.period_s = 0.02;
    self->communication_interface.param_data_frame_head_master = 0xff;
    self->communication_interface.param_data_frame_head_slave = 0xee;

    /* system id */
    // self->system_id_RL.param_Ts = self->param_cur_control_period_s;
    float uin_tmp[5] = {0.06, 0.15, 0.13, 0.3, 0.4};
    memcpy(self->system_id_RL.param_uin_series, uin_tmp, sizeof(uin_tmp));
    self->system_id_RL.param_current_stable_err_condition = 0.0005;
    self->system_id_RL.param_current_buff_size = 300;
    self->system_id_RL.param_current_err_size = 20;
    self->system_id_RL.param_prepare_time = 5000;
    self->system_id_RL.param_normal_R_range_min = 0.1;
    self->system_id_RL.param_normal_R_range_max = 100;
    self->system_id_RL.param_normal_L_range_min = 1e-6;
    self->system_id_RL.param_normal_L_range_max = 1000000e-6;

    /* motor phase check */
    self->motor_phase_check.param_run_on_startup = 1;
    self->motor_phase_check.param_motor_resistance_tolerance_standar_percent = 30;

    /* zazen mode */
    self->zazen_mode.param_en = 0;
    self->zazen_mode.param_trigger_time_s = 1.0;
    self->zazen_mode.param_gain.pos_kp = 1.0;
    self->zazen_mode.param_gain.spd_kp = 0.5;
    self->zazen_mode.param_gain.spd_ki = 0.5;
    self->zazen_mode.param_gain.cur_kp = 0.5;
    self->zazen_mode.param_gain.cur_ki = 0.5;

    /* param settings */
    ParamFurtherSetup(self);
}

void DefaultParam_Init_K1Max_Z(StepperMotorController *self)
{
    memset(self, 0, sizeof(StepperMotorController));

    /* Init stepper_motor_controller */
    self->ConfigParam = DefaultParam_Init_K1Max_Z;
    self->Init = StepperMotorController_Init;
    self->driver_board = &driver_board_motor_drv42_v12;
    self->stepper_motor = &stepper_motor_Corier_4248_BJ42D29_41V07;
    self->encoder = &encoder_MT6826_15bit;
    self->mcu = &mcu_ch32v303CBT6_v12;
    self->controller = &controller_K1Max_Z;
    // self->controller = &controller_ParallelLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    // self->controller = &controller_FhanLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    self->flash_manager_param = &flash_manager_param_v1_0;
    self->param_firmware_version.number.all = (((uint32_t)FIRMWARE_VERSION_MAJOR << 24) | ((uint32_t)FIRMWARE_VERSION_MINOR << 16) | ((uint32_t)FIRMWARE_VERSION_PATCH << 8) | ((uint32_t)FIRMWARE_VERSION_COMPILED));
    self->param_firmware_version.release_date = FIRMWARE_RELEASE_DATE;
    self->param_boot_key = BOOT_SKIP_KEY;
    // self->flash_manager_encoder_table = &flash_manager_encoder_calibration;
    self->logger = &logger_v1_0;

    self->param_flash_key_write_retries_num = 5;

    self->param_system_startup_delay_ms = 100;

    self->param_pwm_period_s = 3.5e-5;
    self->param_task_period_s = 14e-5;

    self->param_use_default_param = FALSE;
    self->param_singleturn_control_mode = TRUE;

    /** elec angle offset */
    self->param_elec_angle_calibration_standar_deg = 15.0F;

    self->param_elec_offset = 152.32; // default

    self->param_phase_order_invert = 1;

    /** rotor block dec */
    self->param_emergency_pin_mode = Emergency_Pin_Mode_Stall;
    self->param_stall_mode = StallMode_Pos;
    self->param_stall_cur_A = 0.7;
    self->param_stall_pos_err_rad = 0.015;

    /* dir of elec offset calibration and encoder_calibtate_official */
    self->param_calibration_dir = -1;

    /* param of encoder calibration and zero offset calibration */
    self->param_encoder_cal_count_max = 200;
    self->param_encoder_read_count = 10;
    self->param_delay_ms_per_step = 10;
    self->param_delay_ms_per_read = 1;
    self->param_ud_cal_set = 0.25;
    self->param_motion_dir = 1;

    /* encoder calibrate official */
    self->param_encoder_calibtate_official_cal_count_max = 200 * 32;
    self->param_encoder_calibtate_official_ud_cal_set = 0.25;
    self->param_encoder_calibration_round_count = 40;

    /* config module */
    self->stepper_motor->ConfigParam(self->stepper_motor);
    self->encoder->ConfigParam(self->encoder);
    self->mcu->ConfigParam(self->mcu);
    self->controller->ConfigParam(self->controller);
    self->driver_board->ConfigParam(self->driver_board);
    self->flash_manager_param->ConfigParam(self->flash_manager_param);
    // self->flash_manager_encoder_table->ConfigParam(self->flash_manager_encoder_table);
    self->logger->ConfigParam(self->logger);
    PeriodCorrect(self);

    /* connect module */
    self->driver_board->mcu = self->mcu;
    self->encoder->mcu = self->mcu;
    self->controller->motor = self->stepper_motor;
    self->step_controller.mcu = self->mcu;
    self->flash_manager_param->mcu = self->mcu;
    self->logger->mcu = self->mcu;

    /*** module param settings ***/
    /* Protection */
    self->protection.Init = Protection_Init;
    self->protection.param_version.number.all = (((uint16_t)PROTECTION_VERSION_MAJOR << 8) | ((uint16_t)PROTECTION_VERSION_MINOR));
    self->protection.param_version.release_date = PROTECTION_RELEASE_DATE;
    self->protection.param_en = 0;
    self->protection.param_enable_report = 0;
    // self->protection.param_check_period_s = self->param_task_period_s;
    self->protection.param_err_code_mask = 0xffffffff;
    self->protection.param_warning_code_mask = 0xffffffff;
    self->protection.param_encoder_mutation_coefficient_upper = 0.5;
    self->protection.param_encoder_mutation_coefficient_lower = 0.1;
    self->protection.param_peak_overcurrent_A = 999.0;
    self->protection.param_continuous_overcurrent_A = 4.0;
    self->protection.param_continuous_overcurrent_time_s = 2.0;
    self->protection.param_speed_over_limit_rad_s = 3000 * RPM2RAD;
    self->protection.param_speed_over_limit_time_s = 0.1;
    self->protection.param_pos_over_limit_max_rad = 999;
    self->protection.param_pos_over_limit_min_rad = -999;
    self->protection.param_pos_cmd_mutation_turns = 0.1;
    self->protection.param_pos_tracking_error_maximum_rad = 0.3;
    self->protection.param_pos_tracking_error_time_s = 0.1;
    self->protection.param_power_voltage_min = 20.0;
    self->protection.param_mcu_temp_max = 115.0;

    /* Chopper param */
    self->chopper.Init = Chopper_Init;
    self->chopper.param_chopper_mode = ChopperMode_SlowDecay;
    self->chopper.param_svpwm_mode = SVPWMMode_2phase8vector;
    self->chopper.param_base_pwm = 0.0;
    self->chopper.param_offset_pwm_en = 0;
    self->chopper.param_offset_pwm = 0.02;
    self->chopper.param_hybrid_decay_ratio = 99999999;

    /* StepController param */
    self->step_controller.Init = StepController_Init;
    self->step_controller.param_pulse_count_max = 65000;
    self->step_controller.param_subdivision = 16;
    self->step_controller.param_pulse_trim_en = 0;
    self->step_controller.param_trim_action_period = 10;
    self->step_controller.param_extra_trim_pulse = 10;

    /* S Curve Init */
    // self->scurve.Init = SCurve_Init;
    // self->scurve.param_period_s = 0.02;
    // self->scurve.param_acc_max = 10;
    // self->scurve.param_speed_max = 100;
    // self->scurve.param_jerk = 1000;

    /* CommunicationInterface */
    self->communication_interface.Init = CommunicationInterface_Init;
    self->communication_interface.param_version.number.all = (((uint16_t)CMD_SYSTEM_VERSION_MAJOR << 8) | ((uint16_t)CMD_SYSTEM_VERSION_MINOR));
    self->communication_interface.param_version.release_date = CMD_SYSTEM_RELEASE_DATE;
    self->communication_interface.param_char_cmd_support = TRUE;
    self->communication_interface.param_slave_addr = SlaveAddr_Invalid;
    self->communication_interface.param_receive_buff_addr = UartRxBuff;
    self->communication_interface.period_s = 0.02;
    self->communication_interface.param_data_frame_head_master = 0xff;
    self->communication_interface.param_data_frame_head_slave = 0xee;

    /* system id */
    // self->system_id_RL.param_Ts = self->param_cur_control_period_s;
    float uin_tmp[5] = {0.06, 0.15, 0.13, 0.3, 0.4};
    memcpy(self->system_id_RL.param_uin_series, uin_tmp, sizeof(uin_tmp));
    self->system_id_RL.param_current_stable_err_condition = 0.0005;
    self->system_id_RL.param_current_buff_size = 300;
    self->system_id_RL.param_current_err_size = 20;
    self->system_id_RL.param_prepare_time = 5000;
    self->system_id_RL.param_normal_R_range_min = 0.1;
    self->system_id_RL.param_normal_R_range_max = 100;
    self->system_id_RL.param_normal_L_range_min = 1e-6;
    self->system_id_RL.param_normal_L_range_max = 1000000e-6;

    /* motor phase check */
    self->motor_phase_check.param_run_on_startup = 1;
    self->motor_phase_check.param_motor_resistance_tolerance_standar_percent = 30;

    /* zazen mode */
    self->zazen_mode.param_en = 0;
    self->zazen_mode.param_trigger_time_s = 1.0;
    self->zazen_mode.param_gain.pos_kp = 1.0;
    self->zazen_mode.param_gain.spd_kp = 0.5;
    self->zazen_mode.param_gain.spd_ki = 0.5;
    self->zazen_mode.param_gain.cur_kp = 0.5;
    self->zazen_mode.param_gain.cur_ki = 0.5;

    /* param settings */
    ParamFurtherSetup(self);
}

void DefaultParam_Init_K1Max_E(StepperMotorController *self)
{
    memset(self, 0, sizeof(StepperMotorController));

    /* Init stepper_motor_controller */
    self->ConfigParam = DefaultParam_Init_K1Max_E;
    self->Init = StepperMotorController_Init;
    self->driver_board = &driver_board_motor_drv42_v12;
    self->stepper_motor = &stepper_motor_default; //&stepper_motor_Moons_4248_MS17HDB3P4250;
    self->encoder = &encoder_MT6826_15bit;
    self->mcu = &mcu_ch32v303CBT6_v12;
    self->controller = &controller_PF019Pro_Z;
    // self->controller = &controller_ParallelLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    // self->controller = &controller_FhanLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    self->flash_manager_param = &flash_manager_param_v1_0;
    self->param_firmware_version.number.all = (((uint32_t)FIRMWARE_VERSION_MAJOR << 24) | ((uint32_t)FIRMWARE_VERSION_MINOR << 16) | ((uint32_t)FIRMWARE_VERSION_PATCH << 8) | ((uint32_t)FIRMWARE_VERSION_COMPILED));
    self->param_firmware_version.release_date = FIRMWARE_RELEASE_DATE;
    self->param_boot_key = BOOT_SKIP_KEY;
    // self->flash_manager_encoder_table = &flash_manager_encoder_calibration;
    self->logger = &logger_v1_0;

    self->param_flash_key_write_retries_num = 5;

    self->param_system_startup_delay_ms = 100;

    self->param_pwm_period_s = 3.5e-5;
    self->param_task_period_s = 14e-5;

    self->param_use_default_param = FALSE;
    self->param_singleturn_control_mode = TRUE;

    /** elec angle offset */
    self->param_elec_angle_calibration_standar_deg = 15.0F;

    self->param_elec_offset = 152.32; // default

    self->param_phase_order_invert = 1;

    /** rotor block dec */
    self->param_emergency_pin_mode = Emergency_Pin_Mode_Stall;
    self->param_stall_mode = StallMode_Pos;
    self->param_stall_cur_A = 0.7;
    self->param_stall_pos_err_rad = 0.015;

    /* dir of elec offset calibration and encoder_calibtate_official */
    self->param_calibration_dir = -1;

    /* param of encoder calibration and zero offset calibration */
    self->param_encoder_cal_count_max = 200;
    self->param_encoder_read_count = 10;
    self->param_delay_ms_per_step = 10;
    self->param_delay_ms_per_read = 1;
    self->param_ud_cal_set = 0.15;
    self->param_motion_dir = 1;

    /* encoder calibrate official */
    self->param_encoder_calibtate_official_cal_count_max = 200 * 32;
    self->param_encoder_calibtate_official_ud_cal_set = 0.15;
    self->param_encoder_calibration_round_count = 40;

    /* config module */
    self->stepper_motor->ConfigParam(self->stepper_motor);
    self->encoder->ConfigParam(self->encoder);
    self->mcu->ConfigParam(self->mcu);
    self->controller->ConfigParam(self->controller);
    self->driver_board->ConfigParam(self->driver_board);
    self->flash_manager_param->ConfigParam(self->flash_manager_param);
    // self->flash_manager_encoder_table->ConfigParam(self->flash_manager_encoder_table);
    self->logger->ConfigParam(self->logger);
    PeriodCorrect(self);

    /* connect module */
    self->driver_board->mcu = self->mcu;
    self->encoder->mcu = self->mcu;
    self->controller->motor = self->stepper_motor;
    self->step_controller.mcu = self->mcu;
    self->flash_manager_param->mcu = self->mcu;
    self->logger->mcu = self->mcu;

    /*** module param settings ***/
    /* Protection */
    self->protection.Init = Protection_Init;
    self->protection.param_version.number.all = (((uint16_t)PROTECTION_VERSION_MAJOR << 8) | ((uint16_t)PROTECTION_VERSION_MINOR));
    self->protection.param_version.release_date = PROTECTION_RELEASE_DATE;
    self->protection.param_en = 0;
    self->protection.param_enable_report = 0;
    // self->protection.param_check_period_s = self->param_task_period_s;
    self->protection.param_err_code_mask = 0xffffffff;
    self->protection.param_warning_code_mask = 0xffffffff;
    self->protection.param_encoder_mutation_coefficient_upper = 0.5;
    self->protection.param_encoder_mutation_coefficient_lower = 0.1;
    self->protection.param_peak_overcurrent_A = 999.0;
    self->protection.param_continuous_overcurrent_A = 4.0;
    self->protection.param_continuous_overcurrent_time_s = 2.0;
    self->protection.param_speed_over_limit_rad_s = 3000 * RPM2RAD;
    self->protection.param_speed_over_limit_time_s = 0.1;
    self->protection.param_pos_over_limit_max_rad = 999;
    self->protection.param_pos_over_limit_min_rad = -999;
    self->protection.param_pos_cmd_mutation_turns = 0.1;
    self->protection.param_pos_tracking_error_maximum_rad = 0.3;
    self->protection.param_pos_tracking_error_time_s = 0.1;
    self->protection.param_power_voltage_min = 20.0;
    self->protection.param_mcu_temp_max = 115.0;

    /* Chopper param */
    self->chopper.Init = Chopper_Init;
    self->chopper.param_chopper_mode = ChopperMode_SlowDecay;
    self->chopper.param_svpwm_mode = SVPWMMode_2phase8vector;
    self->chopper.param_base_pwm = 0.0;
    self->chopper.param_offset_pwm_en = 0;
    self->chopper.param_offset_pwm = 0.02;
    self->chopper.param_hybrid_decay_ratio = 99999999;

    /* StepController param */
    self->step_controller.Init = StepController_Init;
    self->step_controller.param_pulse_count_max = 65000;
    self->step_controller.param_subdivision = 16;
    self->step_controller.param_pulse_trim_en = 0;
    self->step_controller.param_trim_action_period = 10;
    self->step_controller.param_extra_trim_pulse = 10;

    /* S Curve Init */
    // self->scurve.Init = SCurve_Init;
    // self->scurve.param_period_s = 0.02;
    // self->scurve.param_acc_max = 10;
    // self->scurve.param_speed_max = 100;
    // self->scurve.param_jerk = 1000;

    /* CommunicationInterface */
    self->communication_interface.Init = CommunicationInterface_Init;
    self->communication_interface.param_version.number.all = (((uint16_t)CMD_SYSTEM_VERSION_MAJOR << 8) | ((uint16_t)CMD_SYSTEM_VERSION_MINOR));
    self->communication_interface.param_version.release_date = CMD_SYSTEM_RELEASE_DATE;
    self->communication_interface.param_char_cmd_support = TRUE;
    self->communication_interface.param_slave_addr = SlaveAddr_Invalid;
    self->communication_interface.param_receive_buff_addr = UartRxBuff;
    self->communication_interface.period_s = 0.02;
    self->communication_interface.param_data_frame_head_master = 0xff;
    self->communication_interface.param_data_frame_head_slave = 0xee;

    /* system id */
    // self->system_id_RL.param_Ts = self->param_cur_control_period_s;
    float uin_tmp[5] = {0.06, 0.15, 0.13, 0.3, 0.4};
    memcpy(self->system_id_RL.param_uin_series, uin_tmp, sizeof(uin_tmp));
    self->system_id_RL.param_current_stable_err_condition = 0.0005;
    self->system_id_RL.param_current_buff_size = 300;
    self->system_id_RL.param_current_err_size = 20;
    self->system_id_RL.param_prepare_time = 5000;
    self->system_id_RL.param_normal_R_range_min = 0.1;
    self->system_id_RL.param_normal_R_range_max = 100;
    self->system_id_RL.param_normal_L_range_min = 1e-6;
    self->system_id_RL.param_normal_L_range_max = 1000000e-6;

    /* motor phase check */
    self->motor_phase_check.param_run_on_startup = 1;
    self->motor_phase_check.param_motor_resistance_tolerance_standar_percent = 30;

    /* zazen mode */
    self->zazen_mode.param_en = 0;
    self->zazen_mode.param_trigger_time_s = 1.0;
    self->zazen_mode.param_gain.pos_kp = 1.0;
    self->zazen_mode.param_gain.spd_kp = 0.5;
    self->zazen_mode.param_gain.spd_ki = 0.5;
    self->zazen_mode.param_gain.cur_kp = 0.5;
    self->zazen_mode.param_gain.cur_ki = 0.5;

    /* param settings */
    ParamFurtherSetup(self);
}

void DefaultParam_Init_PF018_X(StepperMotorController *self)
{
    memset(self, 0, sizeof(StepperMotorController));

    /* Init stepper_motor_controller */
    self->ConfigParam = DefaultParam_Init_PF018_X;
    self->Init = StepperMotorController_Init;
    self->driver_board = &driver_board_motor_drv42_v12;
    self->stepper_motor = &stepper_motor_Moons_4240_MS17HDB2L420D_01;
    self->encoder = &encoder_MT6826_15bit;
    self->mcu = &mcu_ch32v303CBT6_v12;
    self->controller = &controller_PF018_X;
    // self->controller = &controller_ParallelLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    // self->controller = &controller_FhanLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    self->flash_manager_param = &flash_manager_param_v1_0;
    self->param_firmware_version.number.all = (((uint32_t)FIRMWARE_VERSION_MAJOR << 24) | ((uint32_t)FIRMWARE_VERSION_MINOR << 16) | ((uint32_t)FIRMWARE_VERSION_PATCH << 8) | ((uint32_t)FIRMWARE_VERSION_COMPILED));
    self->param_firmware_version.release_date = FIRMWARE_RELEASE_DATE;
    self->param_boot_key = BOOT_SKIP_KEY;
    // self->flash_manager_encoder_table = &flash_manager_encoder_calibration;
    self->logger = &logger_v1_0;

    self->param_flash_key_write_retries_num = 5;

    self->param_system_startup_delay_ms = 100;

    self->param_pwm_period_s = 3.5e-5;
    self->param_task_period_s = 3.5e-5 * 4;

    self->param_use_default_param = FALSE;
    self->param_singleturn_control_mode = TRUE;

    /** elec angle offset */
    self->param_elec_angle_calibration_standar_deg = 15.0F;

    self->param_elec_offset = 152.32; // default

    self->param_phase_order_invert = 1;

    /** rotor block dec */
    self->param_emergency_pin_mode = Emergency_Pin_Mode_Stall;
    self->param_stall_mode = StallMode_Pos;
    self->param_stall_cur_A = 0.7;
    self->param_stall_pos_err_rad = 0.015;

    /* dir of elec offset calibration and encoder_calibtate_official */
    self->param_calibration_dir = -1;

    /* param of encoder calibration and zero offset calibration */
    self->param_encoder_cal_count_max = 200;
    self->param_encoder_read_count = 10;
    self->param_delay_ms_per_step = 10;
    self->param_delay_ms_per_read = 1;
    self->param_ud_cal_set = 0.15;
    self->param_motion_dir = 1;

    /* encoder calibrate official */
    self->param_encoder_calibtate_official_cal_count_max = 200 * 32;
    self->param_encoder_calibtate_official_ud_cal_set = 0.15;
    self->param_encoder_calibration_round_count = 40;

    /* config module */
    self->stepper_motor->ConfigParam(self->stepper_motor);
    self->encoder->ConfigParam(self->encoder);
    self->mcu->ConfigParam(self->mcu);
    self->controller->ConfigParam(self->controller);
    self->driver_board->ConfigParam(self->driver_board);
    self->flash_manager_param->ConfigParam(self->flash_manager_param);
    // self->flash_manager_encoder_table->ConfigParam(self->flash_manager_encoder_table);
    self->logger->ConfigParam(self->logger);
    PeriodCorrect(self);

    /* connect module */
    self->driver_board->mcu = self->mcu;
    self->encoder->mcu = self->mcu;
    self->controller->motor = self->stepper_motor;
    self->step_controller.mcu = self->mcu;
    self->flash_manager_param->mcu = self->mcu;
    self->logger->mcu = self->mcu;

    /*** module param settings ***/
    /* Protection */
    self->protection.Init = Protection_Init;
    self->protection.param_version.number.all = (((uint16_t)PROTECTION_VERSION_MAJOR << 8) | ((uint16_t)PROTECTION_VERSION_MINOR));
    self->protection.param_version.release_date = PROTECTION_RELEASE_DATE;
    self->protection.param_en = 0;
    self->protection.param_enable_report = 0;
    // self->protection.param_check_period_s = self->param_task_period_s;
    self->protection.param_err_code_mask = 0xffffffff;
    self->protection.param_warning_code_mask = 0xffffffff;
    self->protection.param_encoder_mutation_coefficient_upper = 0.5;
    self->protection.param_encoder_mutation_coefficient_lower = 0.1;
    self->protection.param_peak_overcurrent_A = 999.0;
    self->protection.param_continuous_overcurrent_A = 4.0;
    self->protection.param_continuous_overcurrent_time_s = 2.0;
    self->protection.param_speed_over_limit_rad_s = 3000 * RPM2RAD;
    self->protection.param_speed_over_limit_time_s = 0.1;
    self->protection.param_pos_over_limit_max_rad = 999;
    self->protection.param_pos_over_limit_min_rad = -999;
    self->protection.param_pos_cmd_mutation_turns = 0.1;
    self->protection.param_pos_tracking_error_maximum_rad = 0.3;
    self->protection.param_pos_tracking_error_time_s = 0.1;
    self->protection.param_power_voltage_min = 20.0;
    self->protection.param_mcu_temp_max = 115.0;

    /* Chopper param */
    self->chopper.Init = Chopper_Init;
    self->chopper.param_chopper_mode = ChopperMode_SlowDecay;
    self->chopper.param_svpwm_mode = SVPWMMode_2phase8vector;
    self->chopper.param_base_pwm = 0.0;
    self->chopper.param_offset_pwm_en = 0;
    self->chopper.param_offset_pwm = 0.02;
    self->chopper.param_hybrid_decay_ratio = 99999999;

    /* StepController param */
    self->step_controller.Init = StepController_Init;
    self->step_controller.param_pulse_count_max = 65000;
    self->step_controller.param_subdivision = 16;
    self->step_controller.param_pulse_trim_en = 0;
    self->step_controller.param_trim_action_period = 10;
    self->step_controller.param_extra_trim_pulse = 10;

    /* S Curve Init */
    // self->scurve.Init = SCurve_Init;
    // self->scurve.param_period_s = 0.02;
    // self->scurve.param_acc_max = 10;
    // self->scurve.param_speed_max = 100;
    // self->scurve.param_jerk = 1000;

    /* CommunicationInterface */
    self->communication_interface.Init = CommunicationInterface_Init;
    self->communication_interface.param_version.number.all = (((uint16_t)CMD_SYSTEM_VERSION_MAJOR << 8) | ((uint16_t)CMD_SYSTEM_VERSION_MINOR));
    self->communication_interface.param_version.release_date = CMD_SYSTEM_RELEASE_DATE;
    self->communication_interface.param_char_cmd_support = TRUE;
    self->communication_interface.param_slave_addr = SlaveAddr_Invalid;
    self->communication_interface.param_receive_buff_addr = UartRxBuff;
    self->communication_interface.period_s = 0.02;
    self->communication_interface.param_data_frame_head_master = 0xff;
    self->communication_interface.param_data_frame_head_slave = 0xee;

    /* system id */
    // self->system_id_RL.param_Ts = self->param_cur_control_period_s;
    float uin_tmp[5] = {0.06, 0.15, 0.13, 0.3, 0.4};
    memcpy(self->system_id_RL.param_uin_series, uin_tmp, sizeof(uin_tmp));
    self->system_id_RL.param_current_stable_err_condition = 0.0005;
    self->system_id_RL.param_current_buff_size = 300;
    self->system_id_RL.param_current_err_size = 20;
    self->system_id_RL.param_prepare_time = 5000;
    self->system_id_RL.param_normal_R_range_min = 0.1;
    self->system_id_RL.param_normal_R_range_max = 100;
    self->system_id_RL.param_normal_L_range_min = 1e-6;
    self->system_id_RL.param_normal_L_range_max = 1000000e-6;

    /* motor phase check */
    self->motor_phase_check.param_run_on_startup = 1;
    self->motor_phase_check.param_motor_resistance_tolerance_standar_percent = 30;

    /* zazen mode */
    self->zazen_mode.param_en = 1;
    self->zazen_mode.param_trigger_time_s = 1.0;
    self->zazen_mode.param_gain.pos_kp = 1.0;
    self->zazen_mode.param_gain.spd_kp = 0.5;
    self->zazen_mode.param_gain.spd_ki = 0.5;
    self->zazen_mode.param_gain.cur_kp = 0.5;
    self->zazen_mode.param_gain.cur_ki = 0.5;

    /* param settings */
    ParamFurtherSetup(self);
}

void DefaultParam_Init_PF018_Y(StepperMotorController *self)
{
    memset(self, 0, sizeof(StepperMotorController));

    /* Init stepper_motor_controller */
    self->ConfigParam = DefaultParam_Init_PF018_Y;
    self->Init = StepperMotorController_Init;
    self->driver_board = &driver_board_motor_drv42_v12;
    self->stepper_motor = &stepper_motor_Moons_4248_MS17HD3L4250_02X;
    self->encoder = &encoder_MT6826_15bit;
    self->mcu = &mcu_ch32v303CBT6_v12;
    self->controller = &controller_PF018_Y;
    // self->controller = &controller_ParallelLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    // self->controller = &controller_FhanLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    self->flash_manager_param = &flash_manager_param_v1_0;
    self->param_firmware_version.number.all = (((uint32_t)FIRMWARE_VERSION_MAJOR << 24) | ((uint32_t)FIRMWARE_VERSION_MINOR << 16) | ((uint32_t)FIRMWARE_VERSION_PATCH << 8) | ((uint32_t)FIRMWARE_VERSION_COMPILED));
    self->param_firmware_version.release_date = FIRMWARE_RELEASE_DATE;
    self->param_boot_key = BOOT_SKIP_KEY;
    // self->flash_manager_encoder_table = &flash_manager_encoder_calibration;
    self->logger = &logger_v1_0;

    self->param_flash_key_write_retries_num = 5;

    self->param_system_startup_delay_ms = 100;

    self->param_pwm_period_s = 3.5e-5;
    self->param_task_period_s = 3.5e-5 * 4;

    self->param_use_default_param = FALSE;
    self->param_singleturn_control_mode = TRUE;

    /** elec angle offset */
    self->param_elec_angle_calibration_standar_deg = 15.0F;

    self->param_elec_offset = 553.10; // default

    self->param_phase_order_invert = 1;

    /** rotor block dec */
    self->param_emergency_pin_mode = Emergency_Pin_Mode_Stall;
    self->param_stall_mode = StallMode_Pos;
    self->param_stall_cur_A = 0.7;
    self->param_stall_pos_err_rad = 0.015;

    /* dir of elec offset calibration and encoder_calibtate_official */
    self->param_calibration_dir = -1;

    /* param of encoder calibration and zero offset calibration */
    self->param_encoder_cal_count_max = 200;
    self->param_encoder_read_count = 10;
    self->param_delay_ms_per_step = 10;
    self->param_delay_ms_per_read = 1;
    self->param_ud_cal_set = 0.15;
    self->param_motion_dir = 1;

    /* encoder calibrate official */
    self->param_encoder_calibtate_official_cal_count_max = 200 * 32;
    self->param_encoder_calibtate_official_ud_cal_set = 0.15;
    self->param_encoder_calibration_round_count = 40;

    /* config module */
    self->stepper_motor->ConfigParam(self->stepper_motor);
    self->encoder->ConfigParam(self->encoder);
    self->mcu->ConfigParam(self->mcu);
    self->controller->ConfigParam(self->controller);
    self->driver_board->ConfigParam(self->driver_board);
    self->flash_manager_param->ConfigParam(self->flash_manager_param);
    // self->flash_manager_encoder_table->ConfigParam(self->flash_manager_encoder_table);
    self->logger->ConfigParam(self->logger);
    PeriodCorrect(self);

    /* connect module */
    self->driver_board->mcu = self->mcu;
    self->encoder->mcu = self->mcu;
    self->controller->motor = self->stepper_motor;
    self->step_controller.mcu = self->mcu;
    self->flash_manager_param->mcu = self->mcu;
    self->logger->mcu = self->mcu;

    /*** module param settings ***/
    /* Protection */
    self->protection.Init = Protection_Init;
    self->protection.param_version.number.all = (((uint16_t)PROTECTION_VERSION_MAJOR << 8) | ((uint16_t)PROTECTION_VERSION_MINOR));
    self->protection.param_version.release_date = PROTECTION_RELEASE_DATE;
    self->protection.param_en = 1;
    self->protection.param_enable_report = 0;
    // self->protection.param_check_period_s = self->param_task_period_s;
    self->protection.param_err_code_mask = 0xffffffff;
    self->protection.param_warning_code_mask = 0xffffffff;
    self->protection.param_encoder_mutation_coefficient_upper = 0.5;
    self->protection.param_encoder_mutation_coefficient_lower = 0.1;
    self->protection.param_peak_overcurrent_A = 999.0;
    self->protection.param_continuous_overcurrent_A = 4.0;
    self->protection.param_continuous_overcurrent_time_s = 2.0;
    self->protection.param_speed_over_limit_rad_s = 3000 * RPM2RAD;
    self->protection.param_speed_over_limit_time_s = 0.1;
    self->protection.param_pos_over_limit_max_rad = 999;
    self->protection.param_pos_over_limit_min_rad = -999;
    self->protection.param_pos_cmd_mutation_turns = 0.1;
    self->protection.param_pos_tracking_error_maximum_rad = 0.3;
    self->protection.param_pos_tracking_error_time_s = 0.1;
    self->protection.param_power_voltage_min = 20.0;
    self->protection.param_mcu_temp_max = 115.0;

    /* Chopper param */
    self->chopper.Init = Chopper_Init;
    self->chopper.param_chopper_mode = ChopperMode_SlowDecay;
    self->chopper.param_svpwm_mode = SVPWMMode_2phase8vector;
    self->chopper.param_base_pwm = 0.0;
    self->chopper.param_offset_pwm_en = 0;
    self->chopper.param_offset_pwm = 0.02;
    self->chopper.param_hybrid_decay_ratio = 99999999;

    /* StepController param */
    self->step_controller.Init = StepController_Init;
    self->step_controller.param_pulse_count_max = 65000;
    self->step_controller.param_subdivision = 16;
    self->step_controller.param_pulse_trim_en = 0;
    self->step_controller.param_trim_action_period = 10;
    self->step_controller.param_extra_trim_pulse = 10;

    /* S Curve Init */
    // self->scurve.Init = SCurve_Init;
    // self->scurve.param_period_s = 0.02;
    // self->scurve.param_acc_max = 10;
    // self->scurve.param_speed_max = 100;
    // self->scurve.param_jerk = 1000;

    /* CommunicationInterface */
    self->communication_interface.Init = CommunicationInterface_Init;
    self->communication_interface.param_version.number.all = (((uint16_t)CMD_SYSTEM_VERSION_MAJOR << 8) | ((uint16_t)CMD_SYSTEM_VERSION_MINOR));
    self->communication_interface.param_version.release_date = CMD_SYSTEM_RELEASE_DATE;
    self->communication_interface.param_char_cmd_support = TRUE;
    self->communication_interface.param_slave_addr = SlaveAddr_Invalid;
    self->communication_interface.param_receive_buff_addr = UartRxBuff;
    self->communication_interface.period_s = 0.02;
    self->communication_interface.param_data_frame_head_master = 0xff;
    self->communication_interface.param_data_frame_head_slave = 0xee;

    /* system id */
    // self->system_id_RL.param_Ts = self->param_cur_control_period_s;
    float uin_tmp[5] = {0.06, 0.15, 0.13, 0.3, 0.4};
    memcpy(self->system_id_RL.param_uin_series, uin_tmp, sizeof(uin_tmp));
    self->system_id_RL.param_current_stable_err_condition = 0.0005;
    self->system_id_RL.param_current_buff_size = 300;
    self->system_id_RL.param_current_err_size = 20;
    self->system_id_RL.param_prepare_time = 5000;
    self->system_id_RL.param_normal_R_range_min = 0.1;
    self->system_id_RL.param_normal_R_range_max = 100;
    self->system_id_RL.param_normal_L_range_min = 1e-6;
    self->system_id_RL.param_normal_L_range_max = 1000000e-6;

    /* motor phase check */
    self->motor_phase_check.param_run_on_startup = 1;
    self->motor_phase_check.param_motor_resistance_tolerance_standar_percent = 30;

    /* zazen mode */
    self->zazen_mode.param_en = 1;
    self->zazen_mode.param_trigger_time_s = 1.0;
    self->zazen_mode.param_gain.pos_kp = 1.0;
    self->zazen_mode.param_gain.spd_kp = 0.5;
    self->zazen_mode.param_gain.spd_ki = 0.5;
    self->zazen_mode.param_gain.cur_kp = 0.5;
    self->zazen_mode.param_gain.cur_ki = 0.5;

    /* param settings */
    ParamFurtherSetup(self);
}

void DefaultParam_Init_PF018_Z(StepperMotorController *self)
{
    memset(self, 0, sizeof(StepperMotorController));

    /* Init stepper_motor_controller */
    self->ConfigParam = DefaultParam_Init_PF018_Z;
    self->Init = StepperMotorController_Init;
    self->driver_board = &driver_board_motor_drv42_v12;
    self->stepper_motor = &stepper_motor_Moons_4240_MS17HDB2L420D_01;
    self->encoder = &encoder_MT6826_15bit;
    self->mcu = &mcu_ch32v303CBT6_v12;
    self->controller = &controller_PF018_Z;
    // self->controller = &controller_ParallelLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    // self->controller = &controller_FhanLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    self->flash_manager_param = &flash_manager_param_v1_0;
    self->param_firmware_version.number.all = (((uint32_t)FIRMWARE_VERSION_MAJOR << 24) | ((uint32_t)FIRMWARE_VERSION_MINOR << 16) | ((uint32_t)FIRMWARE_VERSION_PATCH << 8) | ((uint32_t)FIRMWARE_VERSION_COMPILED));
    self->param_firmware_version.release_date = FIRMWARE_RELEASE_DATE;
    self->param_boot_key = BOOT_SKIP_KEY;
    // self->flash_manager_encoder_table = &flash_manager_encoder_calibration;
    self->logger = &logger_v1_0;

    self->param_flash_key_write_retries_num = 5;

    self->param_system_startup_delay_ms = 100;

    self->param_pwm_period_s = 3.5e-5;
    self->param_task_period_s = 14e-5;

    self->param_use_default_param = FALSE;
    self->param_singleturn_control_mode = TRUE;

    /** elec angle offset */
    self->param_elec_angle_calibration_standar_deg = 15.0F;

    self->param_elec_offset = 152.32; // default

    self->param_phase_order_invert = 1;

    /** rotor block dec */
    self->param_emergency_pin_mode = Emergency_Pin_Mode_Stall;
    self->param_stall_mode = StallMode_Pos;
    self->param_stall_cur_A = 0.7;
    self->param_stall_pos_err_rad = 0.015;

    /* dir of elec offset calibration and encoder_calibtate_official */
    self->param_calibration_dir = -1;

    /* param of encoder calibration and zero offset calibration */
    self->param_encoder_cal_count_max = 200;
    self->param_encoder_read_count = 10;
    self->param_delay_ms_per_step = 10;
    self->param_delay_ms_per_read = 1;
    self->param_ud_cal_set = 0.15;
    self->param_motion_dir = 1;

    /* encoder calibrate official */
    self->param_encoder_calibtate_official_cal_count_max = 200 * 32;
    self->param_encoder_calibtate_official_ud_cal_set = 0.15;
    self->param_encoder_calibration_round_count = 40;

    /* config module */
    self->stepper_motor->ConfigParam(self->stepper_motor);
    self->encoder->ConfigParam(self->encoder);
    self->mcu->ConfigParam(self->mcu);
    self->controller->ConfigParam(self->controller);
    self->driver_board->ConfigParam(self->driver_board);
    self->flash_manager_param->ConfigParam(self->flash_manager_param);
    // self->flash_manager_encoder_table->ConfigParam(self->flash_manager_encoder_table);
    self->logger->ConfigParam(self->logger);
    PeriodCorrect(self);

    /* connect module */
    self->driver_board->mcu = self->mcu;
    self->encoder->mcu = self->mcu;
    self->controller->motor = self->stepper_motor;
    self->step_controller.mcu = self->mcu;
    self->flash_manager_param->mcu = self->mcu;
    self->logger->mcu = self->mcu;

    /*** module param settings ***/
    /* Protection */
    self->protection.Init = Protection_Init;
    self->protection.param_version.number.all = (((uint16_t)PROTECTION_VERSION_MAJOR << 8) | ((uint16_t)PROTECTION_VERSION_MINOR));
    self->protection.param_version.release_date = PROTECTION_RELEASE_DATE;
    self->protection.param_en = 0;
    self->protection.param_enable_report = 0;
    // self->protection.param_check_period_s = self->param_task_period_s;
    self->protection.param_err_code_mask = 0xffffffff;
    self->protection.param_warning_code_mask = 0xffffffff;
    self->protection.param_encoder_mutation_coefficient_upper = 0.5;
    self->protection.param_encoder_mutation_coefficient_lower = 0.1;
    self->protection.param_peak_overcurrent_A = 999.0;
    self->protection.param_continuous_overcurrent_A = 4.0;
    self->protection.param_continuous_overcurrent_time_s = 2.0;
    self->protection.param_speed_over_limit_rad_s = 3000 * RPM2RAD;
    self->protection.param_speed_over_limit_time_s = 0.1;
    self->protection.param_pos_over_limit_max_rad = 999;
    self->protection.param_pos_over_limit_min_rad = -999;
    self->protection.param_pos_cmd_mutation_turns = 0.1;
    self->protection.param_pos_tracking_error_maximum_rad = 0.3;
    self->protection.param_pos_tracking_error_time_s = 0.1;
    self->protection.param_power_voltage_min = 20.0;
    self->protection.param_mcu_temp_max = 115.0;

    /* Chopper param */
    self->chopper.Init = Chopper_Init;
    self->chopper.param_chopper_mode = ChopperMode_SlowDecay;
    self->chopper.param_svpwm_mode = SVPWMMode_2phase8vector;
    self->chopper.param_base_pwm = 0.0;
    self->chopper.param_offset_pwm_en = 0;
    self->chopper.param_offset_pwm = 0.02;
    self->chopper.param_hybrid_decay_ratio = 99999999;

    /* StepController param */
    self->step_controller.Init = StepController_Init;
    self->step_controller.param_pulse_count_max = 65000;
    self->step_controller.param_subdivision = 16;
    self->step_controller.param_pulse_trim_en = 0;
    self->step_controller.param_trim_action_period = 10;
    self->step_controller.param_extra_trim_pulse = 10;

    /* S Curve Init */
    // self->scurve.Init = SCurve_Init;
    // self->scurve.param_period_s = 0.02;
    // self->scurve.param_acc_max = 10;
    // self->scurve.param_speed_max = 100;
    // self->scurve.param_jerk = 1000;

    /* CommunicationInterface */
    self->communication_interface.Init = CommunicationInterface_Init;
    self->communication_interface.param_version.number.all = (((uint16_t)CMD_SYSTEM_VERSION_MAJOR << 8) | ((uint16_t)CMD_SYSTEM_VERSION_MINOR));
    self->communication_interface.param_version.release_date = CMD_SYSTEM_RELEASE_DATE;
    self->communication_interface.param_char_cmd_support = TRUE;
    self->communication_interface.param_slave_addr = SlaveAddr_Invalid;
    self->communication_interface.param_receive_buff_addr = UartRxBuff;
    self->communication_interface.period_s = 0.02;
    self->communication_interface.param_data_frame_head_master = 0xff;
    self->communication_interface.param_data_frame_head_slave = 0xee;

    /* system id */
    // self->system_id_RL.param_Ts = self->param_cur_control_period_s;
    float uin_tmp[5] = {0.06, 0.15, 0.13, 0.3, 0.4};
    memcpy(self->system_id_RL.param_uin_series, uin_tmp, sizeof(uin_tmp));
    self->system_id_RL.param_current_stable_err_condition = 0.0005;
    self->system_id_RL.param_current_buff_size = 300;
    self->system_id_RL.param_current_err_size = 20;
    self->system_id_RL.param_prepare_time = 5000;
    self->system_id_RL.param_normal_R_range_min = 0.1;
    self->system_id_RL.param_normal_R_range_max = 100;
    self->system_id_RL.param_normal_L_range_min = 1e-6;
    self->system_id_RL.param_normal_L_range_max = 1000000e-6;

    /* motor phase check */
    self->motor_phase_check.param_run_on_startup = 1;
    self->motor_phase_check.param_motor_resistance_tolerance_standar_percent = 30;

    /* zazen mode */
    self->zazen_mode.param_en = 0;
    self->zazen_mode.param_trigger_time_s = 1.0;
    self->zazen_mode.param_gain.pos_kp = 1.0;
    self->zazen_mode.param_gain.spd_kp = 0.5;
    self->zazen_mode.param_gain.spd_ki = 0.5;
    self->zazen_mode.param_gain.cur_kp = 0.5;
    self->zazen_mode.param_gain.cur_ki = 0.5;

    /* param settings */
    ParamFurtherSetup(self);
}

void DefaultParam_Init_PF018_E(StepperMotorController *self)
{
    memset(self, 0, sizeof(StepperMotorController));

    /* Init stepper_motor_controller */
    self->ConfigParam = DefaultParam_Init_PF018_E;
    self->Init = StepperMotorController_Init;
    self->driver_board = &driver_board_motor_drv42_v12;
    self->stepper_motor = &stepper_motor_default; //&stepper_motor_Moons_4248_MS17HDB3P4250;
    self->encoder = &encoder_MT6826_15bit;
    self->mcu = &mcu_ch32v303CBT6_v12;
    self->controller = &controller_PF019Pro_Z;
    // self->controller = &controller_ParallelLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    // self->controller = &controller_FhanLeso_Moons_MS17HDB3P4250_4248_PF008_XY;
    self->flash_manager_param = &flash_manager_param_v1_0;
    self->param_firmware_version.number.all = (((uint32_t)FIRMWARE_VERSION_MAJOR << 24) | ((uint32_t)FIRMWARE_VERSION_MINOR << 16) | ((uint32_t)FIRMWARE_VERSION_PATCH << 8) | ((uint32_t)FIRMWARE_VERSION_COMPILED));
    self->param_firmware_version.release_date = FIRMWARE_RELEASE_DATE;
    self->param_boot_key = BOOT_SKIP_KEY;
    // self->flash_manager_encoder_table = &flash_manager_encoder_calibration;
    self->logger = &logger_v1_0;

    self->param_flash_key_write_retries_num = 5;

    self->param_system_startup_delay_ms = 100;

    self->param_pwm_period_s = 3.5e-5;
    self->param_task_period_s = 14e-5;

    self->param_use_default_param = FALSE;
    self->param_singleturn_control_mode = TRUE;

    /** elec angle offset */
    self->param_elec_angle_calibration_standar_deg = 15.0F;

    self->param_elec_offset = 152.32; // default

    self->param_phase_order_invert = 1;

    /** rotor block dec */
    self->param_emergency_pin_mode = Emergency_Pin_Mode_Stall;
    self->param_stall_mode = StallMode_Pos;
    self->param_stall_cur_A = 0.7;
    self->param_stall_pos_err_rad = 0.015;

    /* dir of elec offset calibration and encoder_calibtate_official */
    self->param_calibration_dir = -1;

    /* param of encoder calibration and zero offset calibration */
    self->param_encoder_cal_count_max = 200;
    self->param_encoder_read_count = 10;
    self->param_delay_ms_per_step = 10;
    self->param_delay_ms_per_read = 1;
    self->param_ud_cal_set = 0.15;
    self->param_motion_dir = 1;

    /* encoder calibrate official */
    self->param_encoder_calibtate_official_cal_count_max = 200 * 32;
    self->param_encoder_calibtate_official_ud_cal_set = 0.15;
    self->param_encoder_calibration_round_count = 40;

    /* config module */
    self->stepper_motor->ConfigParam(self->stepper_motor);
    self->encoder->ConfigParam(self->encoder);
    self->mcu->ConfigParam(self->mcu);
    self->controller->ConfigParam(self->controller);
    self->driver_board->ConfigParam(self->driver_board);
    self->flash_manager_param->ConfigParam(self->flash_manager_param);
    // self->flash_manager_encoder_table->ConfigParam(self->flash_manager_encoder_table);
    self->logger->ConfigParam(self->logger);
    PeriodCorrect(self);

    /* connect module */
    self->driver_board->mcu = self->mcu;
    self->encoder->mcu = self->mcu;
    self->controller->motor = self->stepper_motor;
    self->step_controller.mcu = self->mcu;
    self->flash_manager_param->mcu = self->mcu;
    self->logger->mcu = self->mcu;

    /*** module param settings ***/
    /* Protection */
    self->protection.Init = Protection_Init;
    self->protection.param_version.number.all = (((uint16_t)PROTECTION_VERSION_MAJOR << 8) | ((uint16_t)PROTECTION_VERSION_MINOR));
    self->protection.param_version.release_date = PROTECTION_RELEASE_DATE;
    self->protection.param_en = 0;
    self->protection.param_enable_report = 0;
    // self->protection.param_check_period_s = self->param_task_period_s;
    self->protection.param_err_code_mask = 0xffffffff;
    self->protection.param_warning_code_mask = 0xffffffff;
    self->protection.param_encoder_mutation_coefficient_upper = 0.5;
    self->protection.param_encoder_mutation_coefficient_lower = 0.1;
    self->protection.param_peak_overcurrent_A = 999.0;
    self->protection.param_continuous_overcurrent_A = 4.0;
    self->protection.param_continuous_overcurrent_time_s = 2.0;
    self->protection.param_speed_over_limit_rad_s = 3000 * RPM2RAD;
    self->protection.param_speed_over_limit_time_s = 0.1;
    self->protection.param_pos_over_limit_max_rad = 999;
    self->protection.param_pos_over_limit_min_rad = -999;
    self->protection.param_pos_cmd_mutation_turns = 0.1;
    self->protection.param_pos_tracking_error_maximum_rad = 0.3;
    self->protection.param_pos_tracking_error_time_s = 0.1;
    self->protection.param_power_voltage_min = 20.0;
    self->protection.param_mcu_temp_max = 115.0;

    /* Chopper param */
    self->chopper.Init = Chopper_Init;
    self->chopper.param_chopper_mode = ChopperMode_SlowDecay;
    self->chopper.param_svpwm_mode = SVPWMMode_2phase8vector;
    self->chopper.param_base_pwm = 0.0;
    self->chopper.param_offset_pwm_en = 0;
    self->chopper.param_offset_pwm = 0.02;
    self->chopper.param_hybrid_decay_ratio = 99999999;

    /* StepController param */
    self->step_controller.Init = StepController_Init;
    self->step_controller.param_pulse_count_max = 65000;
    self->step_controller.param_subdivision = 16;
    self->step_controller.param_pulse_trim_en = 0;
    self->step_controller.param_trim_action_period = 10;
    self->step_controller.param_extra_trim_pulse = 10;

    /* S Curve Init */
    // self->scurve.Init = SCurve_Init;
    // self->scurve.param_period_s = 0.02;
    // self->scurve.param_acc_max = 10;
    // self->scurve.param_speed_max = 100;
    // self->scurve.param_jerk = 1000;

    /* CommunicationInterface */
    self->communication_interface.Init = CommunicationInterface_Init;
    self->communication_interface.param_version.number.all = (((uint16_t)CMD_SYSTEM_VERSION_MAJOR << 8) | ((uint16_t)CMD_SYSTEM_VERSION_MINOR));
    self->communication_interface.param_version.release_date = CMD_SYSTEM_RELEASE_DATE;
    self->communication_interface.param_char_cmd_support = TRUE;
    self->communication_interface.param_slave_addr = SlaveAddr_Invalid;
    self->communication_interface.param_receive_buff_addr = UartRxBuff;
    self->communication_interface.period_s = 0.02;
    self->communication_interface.param_data_frame_head_master = 0xff;
    self->communication_interface.param_data_frame_head_slave = 0xee;

    /* system id */
    // self->system_id_RL.param_Ts = self->param_cur_control_period_s;
    float uin_tmp[5] = {0.06, 0.15, 0.13, 0.3, 0.4};
    memcpy(self->system_id_RL.param_uin_series, uin_tmp, sizeof(uin_tmp));
    self->system_id_RL.param_current_stable_err_condition = 0.0005;
    self->system_id_RL.param_current_buff_size = 300;
    self->system_id_RL.param_current_err_size = 20;
    self->system_id_RL.param_prepare_time = 5000;
    self->system_id_RL.param_normal_R_range_min = 0.1;
    self->system_id_RL.param_normal_R_range_max = 100;
    self->system_id_RL.param_normal_L_range_min = 1e-6;
    self->system_id_RL.param_normal_L_range_max = 1000000e-6;

    /* motor phase check */
    self->motor_phase_check.param_run_on_startup = 1;
    self->motor_phase_check.param_motor_resistance_tolerance_standar_percent = 30;

    /* zazen mode */
    self->zazen_mode.param_en = 0;
    self->zazen_mode.param_trigger_time_s = 1.0;
    self->zazen_mode.param_gain.pos_kp = 1.0;
    self->zazen_mode.param_gain.spd_kp = 0.5;
    self->zazen_mode.param_gain.spd_ki = 0.5;
    self->zazen_mode.param_gain.cur_kp = 0.5;
    self->zazen_mode.param_gain.cur_ki = 0.5;

    /* param settings */
    ParamFurtherSetup(self);
}

/* Global Variable Define ************************************************************/

// volatile StepperMotorController stepper_motor_controller = {.ConfigParam = DefaultParam_Init_default};

// volatile StepperMotorController stepper_motor_controller = {.ConfigParam = DefaultParam_Init_Red_X};
// volatile StepperMotorController stepper_motor_controller = {.ConfigParam = DefaultParam_Init_Red_Y};

// volatile StepperMotorController stepper_motor_controller = {.ConfigParam = DefaultParam_Init_PF019Pro_XY};
// volatile StepperMotorController stepper_motor_controller = {.ConfigParam = DefaultParam_Init_PF019Pro_Z};
// volatile StepperMotorController stepper_motor_controller = {.ConfigParam = DefaultParam_Init_PF019Pro_E};//挤出机

volatile StepperMotorController stepper_motor_controller = {.ConfigParam = DefaultParam_Init_PF008Pro_XY};
// volatile StepperMotorController stepper_motor_controller = {.ConfigParam = DefaultParam_Init_PF008Pro_Z};
// volatile StepperMotorController stepper_motor_controller = {.ConfigParam = DefaultParam_Init_PF008Pro_E};

// volatile StepperMotorController stepper_motor_controller = {.ConfigParam = DefaultParam_Init_Encder3V3KE_X};
// volatile StepperMotorController stepper_motor_controller = {.ConfigParam = DefaultParam_Init_Encder3V3KE_Y};
// volatile StepperMotorController stepper_motor_controller = {.ConfigParam = DefaultParam_Init_Encder3V3KE_Z};
// volatile StepperMotorController stepper_motor_controller = {.ConfigParam = DefaultParam_Init_Encder3V3KE_E};

// volatile StepperMotorController stepper_motor_controller = {.ConfigParam = DefaultParam_Init_K1Max_XY};
// volatile StepperMotorController stepper_motor_controller = {.ConfigParam = DefaultParam_Init_K1Max_Z};
// volatile StepperMotorController stepper_motor_controller = {.ConfigParam = DefaultParam_Init_K1Max_E};

// volatile StepperMotorController stepper_motor_controller = {.ConfigParam = DefaultParam_Init_PF018_X};
// volatile StepperMotorController stepper_motor_controller = {.ConfigParam = DefaultParam_Init_PF018_Y};
// volatile StepperMotorController stepper_motor_controller = {.ConfigParam = DefaultParam_Init_PF018_Z};
// volatile StepperMotorController stepper_motor_controller = {.ConfigParam = DefaultParam_Init_PF018_E};
